Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [patch] memoize string offset lookups
- X-seq: zsh-workers 42479
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [patch] memoize string offset lookups
- Date: Sun, 18 Mar 2018 16:30:24 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=OIL8R2oXdHcsvmxxJ+nlsnPz0etZixhGiZl6B/31wwA=; b=aL1+Eh5Gaob3x1uHAcnDI3AyhXVwzYQGNlfHxBvRBUbtYKdU+Onw77Jg/p9G82UeTH jI2qFBKg/zwMI6He6bcz8/+9hn+VjNCvsnr9McQb0mnk+H+W/IcPIpXgfYCebuaXvejE SXyQtHVt8GllSrcGSn83rUXqq5hVQpPTioMjJrOv0TZq8J3HWML4e/nMkTdr/lzhgyF2 EWjA+GnyULbiCq4t+8vGXnA3fMN5DlqyKScEO+XTk4mKhnpQPsXB8dHVD3TF0lV+Z3Pq pPX9A+Qb4i3QC/BBClTdNSsOskR/ISMVBeZfSI8XSZlehFFNGXyEWNTmSOpc5xvgoEFc uUkA==
- In-reply-to: <20180314024348.GA51231@CptOrmolo.darkstar>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20180314024348.GA51231@CptOrmolo.darkstar>
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