summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjca <jca@openbsd.org>2017-07-24 22:26:12 +0000
committerjca <jca@openbsd.org>2017-07-24 22:26:12 +0000
commit88f528382be0dbb2090319b8347648fb91465e20 (patch)
tree8c6ffcf647fdb914579859a1ce1c701d53526bfb
parentAdd < and > to the comment describind the grammar. (diff)
downloadwireguard-openbsd-88f528382be0dbb2090319b8347648fb91465e20.tar.xz
wireguard-openbsd-88f528382be0dbb2090319b8347648fb91465e20.zip
Use memmove instead of a hand-rolled loop
A tad faster in my HISTFILE "benchmarks". ok tb@
-rw-r--r--bin/ksh/history.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/bin/ksh/history.c b/bin/ksh/history.c
index 93850e54071..c2abb0f924a 100644
--- a/bin/ksh/history.c
+++ b/bin/ksh/history.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: history.c,v 1.59 2017/05/29 13:09:17 tb Exp $ */
+/* $OpenBSD: history.c,v 1.60 2017/07/24 22:26:12 jca Exp $ */
/*
* command history
@@ -617,8 +617,9 @@ histsave(int lno, const char *cmd, int dowrite)
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;