aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-06 14:56:18 +0200
committerMax Kellermann <max@duempel.org>2008-10-06 14:56:18 +0200
commit003f90586c1eab5f17cdc85bf0fc43e5f2a170ec (patch)
treece296ba69b06f31572820d29853af99912967ef7 /src
parent14a15db8fa40bf40047229be92d99c0f5a6d8309 (diff)
downloadmpd-003f90586c1eab5f17cdc85bf0fc43e5f2a170ec.tar.gz
mpd-003f90586c1eab5f17cdc85bf0fc43e5f2a170ec.tar.xz
mpd-003f90586c1eab5f17cdc85bf0fc43e5f2a170ec.zip
wreadln: optimize wreadln_delete_char() with memmove()
Let memmove() do the dirty work on overlapping buffers..
Diffstat (limited to '')
-rw-r--r--src/wreadln.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/wreadln.c b/src/wreadln.c
index 608141f64..89bcc123c 100644
--- a/src/wreadln.c
+++ b/src/wreadln.c
@@ -136,12 +136,13 @@ wreadln_insert_byte(struct wreadln *wr, gint key)
static void
wreadln_delete_char(struct wreadln *wr, size_t x)
{
- size_t i;
+ size_t rest;
+ const size_t length = 1;
assert(x < strlen(wr->line));
- for (i = x; wr->line[i] != 0; i++)
- wr->line[i] = wr->line[i + 1];
+ rest = strlen(&wr->line[x + length]) + 1;
+ memmove(&wr->line[x], &wr->line[x + length], rest);
}
/* libcurses version */