On 6 October 2011 14:09, Tom Schuster <t...@schuster.me> wrote:

> (1) is in  fact really good optimized in modern engines.  (In case you
> are interested search for "Ropes: an alternative to strings")
>

You don't even need ropes to make this fast for a lot of common cases. I
think even a naive implementer would come up with something like this after
a couple of beers:

 - Create the initial string
 - Mark a bit in the string's private handle (say, a bit in a tagged
pointer) when it's referenced
 - Upon += if the referenced bit is true, goto naive +=, else
 - realloc() the underlying storage
 - cat the new string onto the end of the old one
 - this works whether or not realloc() moves the underlying storage, which
it often won't

There's all kinds of ways to optimize operations like this.  Let's not
stifle innovation by over specifying.

Incidentally, Tom suggests a great search. The paper is a good read, but the
Wikipedia article is a faster skim:
http://en.wikipedia.org/wiki/Rope_%28computer_science%29

Wes

-- 
Wesley W. Garland
Director, Product Development
PageMail, Inc.
+1 613 542 2787 x 102
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to