dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: "C. McEnroe" <june@causal.agency>
Cc: dash@vger.kernel.org
Subject: Re: [PATCH v2] Cache the expanded prompt for editline
Date: Wed, 13 Jan 2021 17:18:02 +1100	[thread overview]
Message-ID: <20210113061802.GA6215@gondor.apana.org.au> (raw)
In-Reply-To: <20201223210257.78887-1-june@causal.agency>

C. McEnroe <june@causal.agency> wrote:
> Previously, the prompt would be expanded every time editline called the
> getprompt callback. I think the code may have been written assuming that
> editline only calls getprompt once per prompt, but it may actually call
> it many times, for instance every time you type backspace. This results
> not only in slower editing from expanding complex prompts repeatedly, it
> also consumes more and more stack memory each time getprompt is called.
> This can be seen by setting PS1 to some command substitution, typing
> many characters at the prompt, then holding backspace and observing
> memory usage. Thankfully all this stack memory is freed between prompts
> by the stackmark calls around el_gets.
> 
> This change causes prompt expansion to always happen in the setprompt
> call, as it would when editline is disabled, and a cached copy of the
> prompt is saved for getprompt to return every time editline calls it.
> Since getprompt is no longer doing expansion, the stackmark calls
> surrounding el_gets can be removed.
> ---
> 
> v2: Missed adding breaks when replacing returns with assignments.

What if someone actually wanted the prompt to change?

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

  reply	other threads:[~2021-01-13  6:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-23 19:47 [PATCH] Cache the expanded prompt for editline C. McEnroe
2020-12-23 21:02 ` [PATCH v2] " C. McEnroe
2021-01-13  6:18   ` Herbert Xu [this message]
2021-01-14 15:43     ` June Bug
2021-01-14 20:12       ` Herbert Xu
2021-01-14 20:22         ` June Bug

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=20210113061802.GA6215@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=dash@vger.kernel.org \
    --cc=june@causal.agency \
    /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.
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).