return values instead of playing around with static variables and references

This commit is contained in:
Andrzej Rybczak
2009-06-04 12:19:37 +02:00
parent 1e340211be
commit cd3180d265
4 changed files with 10 additions and 13 deletions

View File

@@ -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<my_char_t> &Scroller(const string &str, size_t width, size_t &pos)
std::basic_string<my_char_t> Scroller(const string &str, size_t width, size_t &pos)
{
static std::basic_string<my_char_t> result;
result.clear();
std::basic_string<my_char_t> s = TO_WSTRING(str);
if (!Config.header_text_scrolling)
return (result = s);
return s;
std::basic_string<my_char_t> result;
size_t len;
# ifdef _UTF8
len = Window::Length(s);

View File

@@ -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<my_char_t> &Scroller(const std::string &, size_t, size_t &);
std::basic_string<my_char_t> Scroller(const std::string &, size_t, size_t &);
#ifdef HAVE_CURL_CURL_H
size_t write_data(char *, size_t, size_t, void *);

View File

@@ -363,11 +363,10 @@ void Info::PrepareSong(MPD::Song &s)
*w << fmtBold << "\nComment: " << fmtBoldEnd << ShowTag(s.GetComment());
}
const basic_buffer<my_char_t> &Info::ShowTag(const string &tag)
basic_buffer<my_char_t> 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

View File

@@ -56,7 +56,7 @@ class Info : public Screen<Scrollpad>
std::string itsFilenamePath;
void PrepareSong(MPD::Song &);
static const basic_buffer<my_char_t> &ShowTag(const std::string &);
static basic_buffer<my_char_t> ShowTag(const std::string &);
# ifdef HAVE_CURL_CURL_H
static void *PrepareArtist(void *);