pvginkel / Jint2

Jint improved
0 stars 0 forks source link

Implement support for string builders #42

Closed pvginkel closed 10 years ago

pvginkel commented 10 years ago

A special string type must be introduced that is optimized for concatenation. The idea here is that the following should automatically be optimized:

var result = '';
for (var i = 0; i < 1000; i++)
{
  result += i;
}

A way to implement this (the way IronJS does it) is to have an alternative string type. When a concatenation is detected, the new string that is produced isn't a string anymore but instead becomes an object that is prepared for concatenation. The primary impact here is that the current runtime system expects a value to be represented by a single native type. This change would introduce a second native type for string which will complicate things.