Ok now it's interesting.
If I build string like this
var large = ".." // large string inside say 1k
var s = large;
while ( s.length < 850 * 1024 ){
s += large;
}
Then when I call utf8value or asciivalue on it it's instantaneous.
So this would point to the fact that small strings like "x" starts of
a wchar, while long ones are optimized into ascii for storage.
On Oct 14, 2:15 pm, ajg <[email protected]> wrote:
> that is not the issue.
> The building of it is actually very fast.
> But once I have the result s string, conversion to either utf8 or
> ascii takes forever in C++.
>
> On Oct 14, 2:08 pm, Stephan Beal <[email protected]> wrote:
>
>
>
>
>
>
>
> > On Fri, Oct 14, 2011 at 11:01 PM, ajg <[email protected]> wrote:
> > > while ( s.length < 850 * 1024 ){
> > > s += "x";
> > > }
>
> > > If you call utf8value or asciivalue on this string it takes about 2-3s
> > > to complete.
>
> > You do understand that this allocates a NEW string on each concatenation,
> > right? JS strings are immutable - you cannot change them in-place. Changing
> > one creates a new copy.
>
> > --
> > ----- stephan bealhttp://wanderinghorse.net/home/stephan/
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users