develooper Front page | perl.perl6.internals | Postings from June 2001

RE: The internal string API

Thread Previous | Thread Next
Hong Zhang
June 20, 2001 10:32
RE: The internal string API
Message ID:

> The one problem with copy-on-write is that, if we implement it in
> we end up paying the price to check it on every string write. (No free 
> depending on the hardware, alas)
> Not that this should shoot down the idea of COW strings, but it is a cost 
> that needs considering. (I suppose we could have a COW subtype of the
> scalar and string scalar)

Even with software implementation, it can come almost free. In this case,
I can use two sizes for each string, readSize and writeSize. The write
operation will check agains writeSize as part of normal bounds check.
If an string is read only, (such as literal), the writeSize will be 0, and
do copy on write. The same scheme applies to string growth. So the price
is just one extra word (writeSize) per string. Since this enables us intern
all literal strings without introducing another data type, I would say the
overhead is minimal.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About