How about having general copy-on-write semantics?  Constant DOMStrings and
DOMStrings passed by value would still share data.  Pass a reference or
pointer where you want mutability.  clone() would then be redundant.  And
we would avoid possible confusion with the aliasing, something I admit to
having fallen into once.  I think the efficiency are the same.

-Rob

>Here is what is happening:
>
>  DOMStrings can be modified.
>
>  If a string field of a node is being assigned with a string of
>  unknown origin, cloning the string first prevents subsequent
>  changes in the original string from being seen in the cloned
>  copy.
>
>  If some field of a node is being set to a string that known to
>  never change, it can simply be assigned.  Sources that are a
>  constant field of another node are safe to use uncloned.
>
>  Cloning is fairly efficient; only a new string handle object
>  needs to be created  The data itself will be shared (until such time
>  as one or the other of the strings is modified.)  And string handles
>  have a custom operator new(), in the interest of speed.


Reply via email to