[wx-dev] Re: UTF-8 for internal string processing
ATS
asteinarson at gmail.com
Tue Apr 1 15:31:59 PDT 2008
> On Tue, 1 Apr 2008 19:48:50 +0000 (UTC) ATS <asteinarson at ...> wrote:
>
> A> It seems to me that wxString does not cache it's iterators, so it
> A> misses that 99% prediction ratio totally, for index access and string
> A> length.
>
> Caching iterators is not free, it results in increased memory consumption
> which can actually degrade the performance more than improve it. So while
The solution in the script engine finally used just 2 global iterators.
That gave the performance boost. One can also a higher, but still fix,
number of iterators. Performance will be close to flat array access
even for a modest fix N (such as 16). (one seldom use that many strings
in an inner loop).
I was parsing input from console tools. When input strings were more than
1000 characters, the app came close to a stand still.
> this could be useful, so far we didn't implement it because we don't have
> sufficient profiling data to prove that it's really needed and that doing
> it is worth the trouble (including not only increased memory consumption
> but also increased code complexity). But nothing prevents from adding this
> in the future if it turns out to be needed.
Complexity increaes yes. Caching has to be done with some care.
What is quite nice is that Length() in average turns into O(1) operation
instead of O(N):
wxString s(...)
for( int ix=0; ix<s.Length(); ix++ )
if( s[ix]=='\t' ) ...
Many people would expect this to be O(N) (and not O(N*N)).
Regards
// ATS.
>
> Regards,
> VZ
>
> _______________________________________________
> wx-dev mailing list
> wx-dev at ...
> http://lists.wxwidgets.org/mailman/listinfo/wx-dev
>
>
More information about the wx-dev
mailing list