On Wed, Aug 19, 2015 at 6:13 AM, Per Hedbor () @ Pike (-) developers
forum <10...@lyskom.lysator.liu.se> wrote:
> Another advantage with this method is that it is reasonably trivial to
> add new string types. As an example that I am seriously considering: A
> string that is a tail port of another string.
>
> The tail-string would be used for this somewhat unfortunate but rather
> common coding pattern:
>
> sscanf( str, "%2c%s", part, str );
>
> and, in a similar manner:
>
> len = file->write(str);
> str = str[written..]
>
> These are both O(n^2), but if tail-of string are added they could both
> be about O(n), only reallocate the data if more than 50% is wasted.

This specific improvement would be useful to this code, although I'm
noticing the slowdown only when I do stupid stuff for benchmarking.

https://github.com/Rosuav/Hogan/blob/master/hogan.pike#L25

Figuring out a good chunk size in application code is hard. If I could
simply code idiomatically without chunking, and let the language worry
about efficiency, it'd be awesome.

ChrisA

Reply via email to