MichaelL_at_frogware.com wrote:
> There are at least four schools of thought on all of this. First, I
> believe that some people think a sufficiently smart compiler could hide
> some/many/most of these issues by, for example, caching information or
> switching to another encoding on the fly.
You could have a 16+16-bit cache that maps scalar-value-index to
byte or word offset. You'd want it an atomic value so you don't
need synchronization. This cache would be updated on each string-ref.
Since normally strings are normally accessed sequentially, each access
is effectively O(1).
Of course it's kind of ugly having a writable cache word in a read-only
string. This might hurt the memory cache in some cases. And it means
allocating a read-only string in read-only memory is difficult.
Of course string-set! is fundamentally broken and useless as I've
said numerous times. It could be replaced by:
(string-append-char! str1 ch)
(string-append-string! str1 str2)
Append ch/str2 to the end to str1. str1 is modified in-place.
--
--Per Bothner
per_at_bothner.com http://per.bothner.com/
Received on Mon Mar 19 2007 - 20:31:55 UTC