diff options
author | Lars Wirzenius <liw@liw.fi> | 2010-10-26 09:37:52 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2010-10-26 09:37:52 +0100 |
commit | 9e54a34b9df1fe94208c9ebaa6b1a38ce88212f4 (patch) | |
tree | dfd9b63b2ae69440f5586acac02b4814e536f520 | |
parent | 32467c0e8782b442c41069172d362e93ef878191 (diff) | |
download | dynstr-9e54a34b9df1fe94208c9ebaa6b1a38ce88212f4.tar.gz |
Reduce string catenation overhead a little bit in readline functions.
When we make a temporary dynstr for the buffered text to be appended,
we can use dynstr_new_from_constant_memory, since the buffer won't
change while the temporary string lives.
Thanks to Richard Braakman for pointing this out.
-rw-r--r-- | dynstr.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -443,7 +443,7 @@ static Dynstr *readline_helper(int (*callback)(FILE *, int), FILE *f, int fd) buf[buflen++] = c; if (buflen == sizeof(buf)) { - temp1 = dynstr_new_from_memory(buf, buflen); + temp1 = dynstr_new_from_constant_memory(buf, buflen); if (temp1 == NULL) goto error; temp2 = dynstr_cat(line, temp1, (void *) NULL); @@ -460,7 +460,7 @@ static Dynstr *readline_helper(int (*callback)(FILE *, int), FILE *f, int fd) } if (buflen > 0) { - temp1 = dynstr_new_from_memory(buf, buflen); + temp1 = dynstr_new_from_constant_memory(buf, buflen); if (temp1 == NULL) goto error; temp2 = dynstr_cat(line, temp1, (void *) NULL); |