Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [patch] memoize string offset lookups



On Mar 13,  9:43pm, Matthew Martin wrote:
}
} (Idea from 42227.)

If you follow that thread through to 42237, the last word on the subject
was that it's probably not worth it to memoize more than the single most
recent call to the function.  In which case it can be done with statics
in the function itself, rather than by expanding the param struct and
adding 20+ bytes to every parameter.

We'd need some real-world information on how common it is to iterate by
characters over two or more parameters in alternation, to know whether
tracking every parameter separately is worth the overhead.

} But in the worst case it hurts.

Iterating backwards over a multibyte character array is always painful.
Related to what Stephane mentions in 42466, it might be worthwhile to
have another optimization in this same bit of code to do the indexing
without the character counting when MB_CUR_MAX == 1.

One thought: Memoize two posistions in the array, one advancing to the
largest index seen so far and the other to half that, so you only have
to recount about half as much if you start skipping backward.  I don't
have a good feel for when the record-keeping becomes more expensive
than the recounting, so this may be a hare-brained scheme.



Messages sorted by: Reverse Date, Date, Thread, Author