From cd3180d265fc4feca919b690860d2b410d1c50bf Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Thu, 4 Jun 2009 12:19:37 +0200 Subject: [PATCH] return values instead of playing around with static variables and references --- src/helpers.cpp | 12 +++++------- src/helpers.h | 4 ++-- src/info.cpp | 5 ++--- src/info.h | 2 +- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/helpers.cpp b/src/helpers.cpp index fa31b03e..f1f00d1e 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -317,10 +317,9 @@ std::string ExtractTopDirectory(const std::string &s) return slash != string::npos ? s.substr(++slash) : s; } -const Buffer &ShowTag(const string &tag) +Buffer ShowTag(const string &tag) { - static Buffer result; - result.Clear(); + Buffer result; if (tag.empty()) result << Config.empty_tags_color << Config.empty_tag << clEnd; else @@ -328,13 +327,12 @@ const Buffer &ShowTag(const string &tag) return result; } -const std::basic_string &Scroller(const string &str, size_t width, size_t &pos) +std::basic_string Scroller(const string &str, size_t width, size_t &pos) { - static std::basic_string result; - result.clear(); std::basic_string s = TO_WSTRING(str); if (!Config.header_text_scrolling) - return (result = s); + return s; + std::basic_string result; size_t len; # ifdef _UTF8 len = Window::Length(s); diff --git a/src/helpers.h b/src/helpers.h index 4f6e68b1..bb929d0b 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -70,9 +70,9 @@ std::string GetLineValue(std::string &, char = '"', char = '"', bool = 0); void RemoveTheWord(std::string &s); std::string ExtractTopDirectory(const std::string &); -const Buffer &ShowTag(const std::string &); +Buffer ShowTag(const std::string &); -const std::basic_string &Scroller(const std::string &, size_t, size_t &); +std::basic_string Scroller(const std::string &, size_t, size_t &); #ifdef HAVE_CURL_CURL_H size_t write_data(char *, size_t, size_t, void *); diff --git a/src/info.cpp b/src/info.cpp index b2ec2f3e..ee14c9d7 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -363,11 +363,10 @@ void Info::PrepareSong(MPD::Song &s) *w << fmtBold << "\nComment: " << fmtBoldEnd << ShowTag(s.GetComment()); } -const basic_buffer &Info::ShowTag(const string &tag) +basic_buffer Info::ShowTag(const string &tag) { # ifdef _UTF8 - static WBuffer result; - result.Clear(); + WBuffer result; if (tag.empty()) result << Config.empty_tags_color << ToWString(Config.empty_tag) << clEnd; else diff --git a/src/info.h b/src/info.h index 49769935..0dd27753 100644 --- a/src/info.h +++ b/src/info.h @@ -56,7 +56,7 @@ class Info : public Screen std::string itsFilenamePath; void PrepareSong(MPD::Song &); - static const basic_buffer &ShowTag(const std::string &); + static basic_buffer ShowTag(const std::string &); # ifdef HAVE_CURL_CURL_H static void *PrepareArtist(void *);