I've just commited a small changeset in order to compute the string length only once in the function. But yes, we could rely on the computed length earlier in the body processing.
I wonder if fixing the loop would mean that we could remove the >50k limitation. It should only have to iterate 450,000*2 times which isn't *that* expensive. =) -- justin