Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

While on it, optimize a bit the way the textboxes text is recomputed.

  • Loading branch information...
commit 71a3edf1c2826fd305c297caefd6c94569d1498a 1 parent af98fa2
Yohann Ferreira authored
Showing with 20 additions and 0 deletions.
  1. +4 −0 src/common/gui/textbox.cpp
  2. +14 −0 src/utils.cpp
  3. +2 −0  src/utils.h
View
4 src/common/gui/textbox.cpp
@@ -257,6 +257,10 @@ void TextBox::SetDisplayText(const ustring &text)
return;
}
+ // If the text hasn't changed, don't recompute the textbox.
+ if (_text_save == text)
+ return;
+
_text_save = text;
_ReformatText();
View
14 src/utils.cpp
@@ -236,6 +236,20 @@ ustring &ustring::operator = (const ustring &s)
return *this;
} // ustring & ustring::operator = (const ustring &s)
+// Compare two substrings
+bool ustring::operator == (const ustring &s)
+{
+ size_t len = length();
+ if (s.length() != len)
+ return false;
+
+ for(size_t j = 0; j < len; ++j) {
+ if (_str[j] != s[j] )
+ return false;
+ }
+
+ return true;
+} // bool ustring::operator == (const ustring &s)
// Finds a character within a string, starting at pos. If nothing is found, npos is returned
size_t ustring::find(uint16 c, size_t pos) const
View
2  src/utils.h
@@ -312,6 +312,8 @@ class ustring
ustring &operator = (const ustring &s);
+ bool operator == (const ustring &s);
+
uint16 &operator [](size_t pos) {
return _str[pos];
}

2 comments on commit 71a3edf

@IkarusDowned

just a thought, you may want to make those operators const. so:
bool operator == (const ustring &s) const;

@Bertram25
Owner

true, I'll do, thanks!

Please sign in to comment.
Something went wrong with that request. Please try again.