Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
small refactoring in globals.cpp
frithjofh:
--- Quote ---Heh, it turned out that your version of GetStringFromArray is a lot slower than the original, because you're using operator+. ::)
--- End quote ---
instead of two times append or += ?
corrected...
--- Quote ---And it turned out that the difference is not that big that I thought it will be.
--- End quote ---
the difference between which versions? original and my version? my version and your version? I mean between your version and my version there is a factor of three, I think that is much, although in absolute numbers it is only msec scale.
frithjofh:
corrected patch. still contains my version of GetStringFromArray() until better version from obfuscated arrives, or what ever the decision may be...
please test and comment on EscapeSpaces()
oBFusCATed:
I'm talking about the non-trimming case. With my version it is slightly faster than your version.
The trimming version is way faster, because it doesn't do trimming, which is slow.
I've done more testing on the EscapeSpaces function and it seems that your fix is an improvement only in wx2.8. With wx3.0 it doesn't make a difference.
frithjofh:
ok. so just leave it as is, right?
frithjofh:
@obfuscated
made another attempt on GetArrayFromString(). if you don't mind, could you give it a run in your testing harness to see its performance?
--- Code: ---wxArrayString GetArrayFromString_3(const wxString& text, const wxString& separator, bool trimSpaces)
{
if ( text.empty() )
return wxArrayString();
const size_t seplen = separator.length();
size_t start_pos = 0;
size_t sep_pos = 0;
wxArrayString out;
if (trimSpaces)
{
while (sep_pos != wxString::npos)
{
start_pos = text.find_first_not_of(_T(" \t\n\r"), start_pos);
if (start_pos == wxString::npos)
break;
sep_pos = text.find(separator, start_pos);
if (sep_pos != start_pos)
{
const size_t end_pos = text.find_last_not_of(_T(" \t\n\r"), (sep_pos == wxString::npos) ? wxString::npos : sep_pos - 1);
out.push_back(text.substr(start_pos, end_pos - start_pos + 1));
}
start_pos = sep_pos + seplen;
}
}
else
{
while (sep_pos != wxString::npos)
{
sep_pos = text.find(separator, start_pos);
if ( sep_pos != start_pos )
out.push_back(text.substr(start_pos, (sep_pos == wxString::npos) ? wxString::npos : sep_pos - start_pos));
start_pos = sep_pos + seplen;
if (start_pos >= text.length())
break;
}
}
return out;
}
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version