[wx-dev] Re: wxArray::Join and wxArray::Split

Armel Asselin asselin.armel at wanadoo.fr
Fri Jan 19 08:58:47 PST 2007


> I gave the argument in the very beginning. If you don't escape the
> separators you can save one thing and restore something different. If you
> don't see why is this a problem, I'm afraid I can't explain it any better.
but this is maybe not what everybody else expect from Join, at least, this 
is not what i (always) expect.
yes sometime one can use Join/Split as a pair but not always.

> AA> OK don't care, people will then continue to do their Join as "text =
> AA> wxT(""); for (i=0; i<length; +i) text += array[i]", they will still 
> claim
> AA> that wx is damn slow, and we here will wonder 'but why do they say 
> that'.
>
> The loop will be hardly slower than Join() (faster in fact). And what does
> the API design have to do with performance anyhow?
the above loop is O(n^2) (because of copy/reallocation induced by +=) and if 
Join is coded this way it would really be dramatic. the general expectation 
from a Join command is O(N)
if I'd like to have even the simple Join without separator coded in the 
framework, it is basically because such loop can be optimized to be, as 
expected, in linear time with respect to the size of joined text (and 
extremely few people will do the proper reserve( ) call that allows this).

Regards
Armel






More information about the wx-dev mailing list