zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: [patch] memoize string offset lookups
Date: Sun, 18 Mar 2018 16:30:24 -0700	[thread overview]
Message-ID: <180318163024.ZM9068@torch.brasslantern.com> (raw)
In-Reply-To: <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.


      reply	other threads:[~2018-03-18 23:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-14  2:43 Matthew Martin
2018-03-18 23:30 ` Bart Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=180318163024.ZM9068@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).