From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: PATCH Re: (bug report) Starting zsh takes ~5 seconds with the latest commits after 20th of September with big history file
Date: Sat, 02 Oct 2010 12:41:11 -0700 [thread overview]
Message-ID: <101002124116.ZM8699@torch.brasslantern.com> (raw)
In-Reply-To: <alpine.LNX.2.01.1009261643520.30023@hp>
On Sep 26, 9:26pm, Benjamin R. Haskell wrote:
} Subject: Re: (bug report) Starting zsh takes ~5 seconds with the latest co
}
} On Sun, 26 Sep 2010, Bart Schaefer wrote:
}
} > Probably the right thing to do is:
} >
} > (1) have an option for the new behavior (HIST_LEX_WORDS ?);
} >
} > (2) implicitly turn that option off on the way through shell exit, so
} > history rewrites/comparisons use faster processing.
}
} Personally, I don't think I'd ever turn on a HIST_LEX_WORDS option.
}
} Starting to regret noticing the problem in the first place. :-\
I'm sure it's best that somebody did.
Here's a patch for part (2) of the suggestion above, I'll leave it to
someone else to add the option -- it should be pretty obvious where to
check for it.
Most of the diff is re-indentation. This patch *follows* 28295 (plus
the unposted tweak that PWS committed).
Index: Src/hist.c
--- ../current/Src/hist.c 2010-09-26 13:05:43.000000000 -0700
+++ Src/hist.c 2010-10-02 12:33:08.000000000 -0700
@@ -2335,61 +2335,84 @@
else
he->ftim = ftim;
- /*
- * Divide up the words. Attempt to do this using the lexer.
- */
nwordpos = 0;
start = pt;
- wordlist = bufferwords(NULL, pt, NULL);
- he->nwords = countlinknodes(wordlist);
- if (2*he->nwords > nwords) {
- nwords = 2*he->nwords;
- words = (short *)realloc(words, nwords*sizeof(short));
- }
- while (firstnode(wordlist)) {
- char *word = uremnode(wordlist, firstnode(wordlist));
-
- while (inblank(*pt))
- pt++;
- if (!strpfx(word, pt)) {
- int bad = 0;
- /*
- * Oddity 1: newlines turn into semicolons.
- */
- if (!strcmp(word, ";"))
- continue;
- /*
- * Oddity 2: !'s turn into |'s.
- */
- while (*pt) {
- if (!*word) {
- bad = 1;
- break;
- }
- if (*pt == *word ||
- (*pt == '!' && *word == '|')) {
+
+ if (readflags & HFILE_FAST) {
+ /*
+ * Divide up the words. We don't care how it lexes,
+ * so just look for white-space.
+ */
+ do {
+ while (inblank(*pt))
+ pt++;
+ if (*pt) {
+ if (nwordpos >= nwords)
+ words = (short *) realloc(words,
+ (nwords += 64)*sizeof(short));
+ words[nwordpos++] = pt - start;
+ while (*pt && !inblank(*pt))
pt++;
- word++;
- } else {
- bad = 1;
- break;
- }
+ words[nwordpos++] = pt - start;
}
- if (bad) {
+ } while (*pt);
+
+ he->nwords = nwordpos/2;
+ } else {
+ /*
+ * Divide up the words. Attempt to do this using the lexer.
+ */
+ wordlist = bufferwords(NULL, pt, NULL);
+ he->nwords = countlinknodes(wordlist);
+ if (2*he->nwords > nwords) {
+ nwords = 2*he->nwords;
+ words = (short *)realloc(words, nwords*sizeof(short));
+ }
+ while (firstnode(wordlist)) {
+ char *word = uremnode(wordlist, firstnode(wordlist));
+
+ while (inblank(*pt))
+ pt++;
+ if (!strpfx(word, pt)) {
+ int bad = 0;
+ /*
+ * Oddity 1: newlines turn into semicolons.
+ */
+ if (!strcmp(word, ";"))
+ continue;
+ /*
+ * Oddity 2: !'s turn into |'s.
+ */
+ while (*pt) {
+ if (!*word) {
+ bad = 1;
+ break;
+ }
+ if (*pt == *word ||
+ (*pt == '!' && *word == '|')) {
+ pt++;
+ word++;
+ } else {
+ bad = 1;
+ break;
+ }
+ }
+ if (bad) {
#ifdef DEBUG
- dputs(ERRMSG("bad wordsplit reading history: %s\nat: %s"
- "\nword: %s"),
- start, pt, word);
+ dputs(ERRMSG("bad wordsplit reading history: %s"
+ "\nat: %s\nword: %s"),
+ start, pt, word);
#endif
- words[nwordpos++] = pt - start;
- pt += strlen(pt);
- words[nwordpos++] = pt - start;
- break;
+ words[nwordpos++] = pt - start;
+ pt += strlen(pt);
+ words[nwordpos++] = pt - start;
+ break;
+ }
}
+ words[nwordpos++] = pt - start;
+ pt += strlen(word);
+ words[nwordpos++] = pt - start;
}
- words[nwordpos++] = pt - start;
- pt += strlen(word);
- words[nwordpos++] = pt - start;
}
if (he->nwords) {
--
next prev parent reply other threads:[~2010-10-02 19:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-26 18:12 Evgeny Burmentyev
2010-09-26 20:15 ` Bart Schaefer
2010-09-27 1:26 ` Benjamin R. Haskell
2010-10-02 19:41 ` Bart Schaefer [this message]
2010-10-02 19:54 ` PATCH " Bart Schaefer
2010-10-02 18:58 ` Peter Stephenson
2010-10-02 20:04 ` Bart Schaefer
2010-10-02 21:06 ` Peter Stephenson
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=101002124116.ZM8699@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).