Found while trying to make ksh(1) startup fast again. This saves ~0.1s
at startup here. (HISTSIZE=20000, wc -l ksh_history -> 24551)
ok?
Index: history.c
===================================================================
RCS file: /d/cvs/src/bin/ksh/history.c,v
retrieving revision 1.59
diff -u -p -p -u -r1.59 history.c
--- history.c 29 May 2017 13:09:17 -0000 1.59
+++ history.c 24 Jul 2017 18:57:16 -0000
@@ -617,8 +617,9 @@ histsave(int lno, const char *cmd, int d
hp = histptr;
if (++hp >= history + histsize) { /* remove oldest command */
afree(*history, APERM);
- for (hp = history; hp < history + histsize - 1; hp++)
- hp[0] = hp[1];
+ memmove(history, history + 1,
+ (histsize - 1) * sizeof(*history));
+ hp = histptr;
}
*hp = c;
histptr = hp;
--
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE