
On 08/02/13 22:44, Jeffrey Yasskin wrote:
I'm sure the WebKit project would welcome a patch demonstrating that flyweights are a more efficient technique for CSS matching. I don't expect they are because these values are built up through several mutations, and a hash table lookup plus a copy on each mutation sounds more expensive than the current copy-on-write system.
I don't pretend to know anything about what WebKit is actually doing. I interpreted what you said to mean that they want all values that are equal to use the same object. In that case the logical approach is indeed to use a flyweight factory. I think I just misunderstood what this was about; maybe they want to do partial COW on subtrees to minimize memory usage for redundant information, which is a whole different beast. COW on whole data structures is useless, but it is very useful when partial sharing is involved. That is not, however, the case that was presented here.