Skip to content

Commit

Permalink
BasicMarquee: change "text" parameter to std::string_view
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Sep 1, 2024
1 parent 466f9d0 commit 6acd423
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/BasicMarquee.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ BasicMarquee::ScrollString() const noexcept
}

bool
BasicMarquee::Set(unsigned _width, const char *_text) noexcept
BasicMarquee::Set(unsigned _width, std::string_view _text) noexcept
{
assert(_text != nullptr);

if (_width == width && text == _text)
/* no change, do nothing (and, most importantly, do
not reset the current offset!) */
Expand Down
2 changes: 1 addition & 1 deletion src/BasicMarquee.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public:
* @param text the text in the locale charset
* @return false if nothing was changed
*/
bool Set(unsigned width, const char *text) noexcept;
bool Set(unsigned width, std::string_view _text) noexcept;

/**
* Removes the text. It may be reused with Set().
Expand Down
2 changes: 1 addition & 1 deletion src/StatusBar.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ StatusBar::Update(const struct mpd_status *status,
StringWidthMB(center_text.c_str());
if (width > 3 && center_width > (unsigned)width) {
hscroll.Set({(int)left_width, 0}, width,
center_text.c_str(),
center_text,
Style::STATUS);
} else {
hscroll.Clear();
Expand Down
4 changes: 1 addition & 3 deletions src/hscroll.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ hscroll::OnTimer() noexcept
}

void
hscroll::Set(Point _position, unsigned _width, const char *_text,
hscroll::Set(Point _position, unsigned _width, std::string_view _text,
Style _style, attr_t _attr) noexcept
{
assert(_text != nullptr);

position = _position;
style = _style;
attr = _attr;
Expand Down
2 changes: 1 addition & 1 deletion src/hscroll.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public:
* every second with the current window attributes. Call
* hscroll_clear() to disable it.
*/
void Set(Point _position, unsigned width, const char *text,
void Set(Point _position, unsigned width, std::string_view text,
Style style, attr_t attr=0) noexcept;

/**
Expand Down

0 comments on commit 6acd423

Please sign in to comment.