Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/tmux/dist Optimise by simplifying.



details:   https://anonhg.NetBSD.org/src/rev/94352cf982e8
branches:  trunk
changeset: 770181:94352cf982e8
user:      joerg <joerg%NetBSD.org@localhost>
date:      Fri Oct 07 10:38:02 2011 +0000

description:
Optimise by simplifying.

diffstat:

 external/bsd/tmux/dist/cmd-string.c |  41 ++++++++++++++++++++----------------
 1 files changed, 23 insertions(+), 18 deletions(-)

diffs (93 lines):

diff -r 14184ee9d459 -r 94352cf982e8 external/bsd/tmux/dist/cmd-string.c
--- a/external/bsd/tmux/dist/cmd-string.c       Fri Oct 07 10:30:21 2011 +0000
+++ b/external/bsd/tmux/dist/cmd-string.c       Fri Oct 07 10:38:02 2011 +0000
@@ -1,4 +1,4 @@
-/* $Id: cmd-string.c,v 1.3 2011/08/17 18:48:36 jmmv Exp $ */
+/* $Id: cmd-string.c,v 1.4 2011/10/07 10:38:02 joerg Exp $ */
 
 /*
  * Copyright (c) 2008 Nicholas Marriott <nicm%users.sourceforge.net@localhost>
@@ -64,7 +64,7 @@
        int             ch, i, argc, rval;
        char          **argv, *buf, *t;
        const char     *whitespace, *equals;
-       size_t          len;
+       size_t          len, len2;
 
        argv = NULL;
        argc = 0;
@@ -84,25 +84,28 @@
                case '\'':
                        if ((t = cmd_string_string(s, &p, '\'', 0)) == NULL)
                                goto error;
-                       buf = xrealloc(buf, 1, len + strlen(t) + 1);
-                       strlcpy(buf + len, t, strlen(t) + 1);
-                       len += strlen(t);
+                       len2 = strlen(t);
+                       buf = xrealloc(buf, 1, len + len2 + 1);
+                       memcpy(buf + len, t, len2 + 1);
+                       len += len2;
                        xfree(t);
                        break;
                case '"':
                        if ((t = cmd_string_string(s, &p, '"', 1)) == NULL)
                                goto error;
-                       buf = xrealloc(buf, 1, len + strlen(t) + 1);
-                       strlcpy(buf + len, t, strlen(t) + 1);
-                       len += strlen(t);
+                       len2 = strlen(t);
+                       buf = xrealloc(buf, 1, len + len2 + 1);
+                       memcpy(buf + len, t, len2 + 1);
+                       len += len2;
                        xfree(t);
                        break;
                case '$':
                        if ((t = cmd_string_variable(s, &p)) == NULL)
                                goto error;
-                       buf = xrealloc(buf, 1, len + strlen(t) + 1);
-                       strlcpy(buf + len, t, strlen(t) + 1);
-                       len += strlen(t);
+                       len2 = strlen(t);
+                       buf = xrealloc(buf, 1, len + len2 + 1);
+                       strlcpy(buf + len, t, len2 + 1);
+                       len += len2;
                        xfree(t);
                        break;
                case '#':
@@ -149,9 +152,10 @@
                        if (buf == NULL) {
                                if ((t = cmd_string_expand_tilde(s, &p)) == NULL)
                                        goto error;
-                               buf = xrealloc(buf, 1, len + strlen(t) + 1);
-                               strlcpy(buf + len, t, strlen(t) + 1);
-                               len += strlen(t);
+                               len2 = strlen(t);
+                               buf = xrealloc(buf, 1, len + len2 + 1);
+                               memcpy(buf + len, t, len2 + 1);
+                               len += len2;
                                xfree(t);
                                break;
                        }
@@ -187,7 +191,7 @@
 {
        int     ch;
        char   *buf, *t;
-       size_t  len;
+       size_t  len, len2;
 
        buf = NULL;
        len = 0;
@@ -221,9 +225,10 @@
                                break;
                        if ((t = cmd_string_variable(s, p)) == NULL)
                                goto error;
-                       buf = xrealloc(buf, 1, len + strlen(t) + 1);
-                       strlcpy(buf + len, t, strlen(t) + 1);
-                       len += strlen(t);
+                       len2 = strlen(t);
+                       buf = xrealloc(buf, 1, len + len2 + 1);
+                       memcpy(buf + len, t, len2 + 1);
+                       len += len2;
                        xfree(t);
                        continue;
                }



Home | Main Index | Thread Index | Old Index