Skip to content

Commit

Permalink
Use iterators to traverse through strings (#719)
Browse files Browse the repository at this point in the history
Documentation says at <https://docs.wxwidgets.org/latest/classwx_string.html>
that accessing the character by index should be avoided.
  • Loading branch information
tobiolo authored Sep 20, 2024
1 parent 6726edc commit 8a86a1a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/text.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ struct Text {

wxString htmlify(wxString &str) {
wxString r;
loop(i, str.Len()) {
switch (str[i].GetValue()) {
for(auto cref : str) {
wxChar c = cref.GetValue();
switch(c) {
case '&': r += L"&amp;"; break;
case '<': r += L"&lt;"; break;
case '>': r += L"&gt;"; break;
default: r += str[i];
default: r += c;
}
}
return r;
Expand Down

0 comments on commit 8a86a1a

Please sign in to comment.