[OpenLayers-Dev] VML rendering in IE is slow with big geometries. Proposed Fix.

Christopher Schmidt crschmidt at metacarta.com
Tue Oct 16 22:09:33 EDT 2007

On Wed, Oct 17, 2007 at 11:58:17AM +1000, Roald de Wit wrote:
> The same slowdown most probably applies to the other drawing methods in
> this class.
> My question is: what would be the best way to tackle this? 

Interesting. I'd always followed the type of behavior you're suggsting
in Python, but had never known it was needed in JS. (It's always bugged
me that we just shoved strings together in Javascript, but it seemed
like everyone did it, so I didn't question.)

The typical way I do this in Python is to just do the equivilant of:

var stringList = [];
for (var i = 0; i < 10000; i++) { stringList.push('foo'); }
var string = stringList.join("");

I think we can even skip the .join("") and use .toString() in JS, but I
have no idea how portable that is, and it feels slightly hacky.

So, I don't see any need for a stringBuffer object, since it would just
be an array (with 'push' replaced with 'append'). 

With these performance numbers in hand, I think that migrating any
significant use of string concatanation -- which I think only includes
the renderers, and maybe things like getParameterString -- to be array
based makes sense, and I'm in support of that path. It probably makes
sense to write at least basic tests for the renderer functionality
before proceeding with this, to ensure that it doesn't break with the
new code in any way that we can be aware of ahead of time.  

Christopher Schmidt

More information about the Dev mailing list