[wx-dev] Re: UTF-8 for internal string processing
Vaclav Slavik
vslavik at fastmail.fm
Tue Apr 1 15:49:50 PDT 2008
ATS wrote:
> Vadim wrote:
> > Caching iterators is not free, it results in increased memory
> > consumption which can actually degrade the performance more than
> > improve it.
Indeed. Something as simple as moving wxString's
wxStringIteratorNodeHead out of wxString itself and into different
area of memory can result in significant speed drop
(where "significant" is in the context of code that does nothing
other than creating and destroying iterators).
> The solution in the script engine finally used just 2 global
> iterators.
That's a nice touch, but it has drawbacks too: because wx supports
threads, it would have to use either locking or TLS, which costs
performance too.
> 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)).
Yes. Vadim's point was that we can implement this optimization *if*
it's clear it is necessary (read: we have hard data showing
significant performance drop in real-life use that can't be easily
avoided or that is widespread). Two things speak against it:
a) most strings are small and so the difference is negligible
b) it's often (e.g. every time for loop like above is used) trivial to
change the code to use iterators
That's why we were hesitant to spend more time on optimizing wxString
until we _know_ there are real problems in the wild.
Regards,
Vaclav
--
PGP key: 0x465264C9, available from http://pgp.mit.edu/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.wxwidgets.org/pipermail/wx-dev/attachments/20080402/852a35e7/attachment.pgp
More information about the wx-dev
mailing list