Re: Re: Unicode string iterator performance

From: Date: Fri, 03 Feb 2006 10:44:10 +0000
Subject: Re: Re: Unicode string iterator performance
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-21785@lists.php.net to get a copy of this message
First of all I was simply proposing a very generic concept without bothering about the implementation on purpose. If it's not feasible then simply ignore it. Marcus Boerger wrote:
caching? There is nothing to cache. And even if we would do that we would make every string an object since we would need to invalidate the position cache on write operations. Also i agree with the others that most common
Tracking changes to the string could be tricky, agreed. I don't know enough about the internal handling of strings, from the user perspective PHP strings look somewhat immutable but that could be very wrong internally, you know better than me. Changing Unicode strings in place sounds kinda tricky to me too so I'd have expected that to the encapsulated somewhere.
And *I* never had code where I used the same position twice. Besides the all
You don't need to access the exact same position. If you know the last array index plus the Unicode offset then you can step by Unicode characters from there which would result to one single Unicode step for iterating over a string. But would also work for $a[$i += 2] as opposed to the originally proposed TextIterator. And if there's a way to step backwards then $a[$i -= 2] could work too.
So i am convinced that the cache would only blow up the code, make everything much more complex and in the end slow down php.
Could well be. It was just an idea, feel free to ignore it ;-) - Chris

« previous php.internals (#21785) next »