[hackers] [sbase] xargs: minor optimizations || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Sat, 28 Mar 2015 22:03:53 +0100 (CET)

commit 8e486d5282ebca8583e427d168030ca6b2d5815e
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Fri Mar 27 22:45:03 2015 +0100

    xargs: minor optimizations

diff --git a/xargs.c b/xargs.c
index d39679e..de09ae9 100644
--- a/xargs.c
+++ b/xargs.c
_AT_@ -234,12 +234,13 @@ main(int argc, char *argv[])
                         }
                 } else {
                         cmd[i] = estrdup("/bin/echo");
- argsz += strlen(cmd[i]) + 1;
+ argsz += strlen("/bin/echo") + 1;
                         i++;
                 }
                 while (leftover || (arg = poparg())) {
- if (argsz + strlen(arg) + 1 > argmaxsz || i >= NARGS - 1) {
- if (strlen(arg) + 1 > argmaxsz) {
+ arglen = strlen(arg);
+ if (argsz + arglen >= argmaxsz || i >= NARGS - 1) {
+ if (arglen >= argmaxsz) {
                                         weprintf("insufficient argument space\n");
                                         if (xflag)
                                                 exit(1);
_AT_@ -248,7 +249,7 @@ main(int argc, char *argv[])
                                 break;
                         }
                         cmd[i] = estrdup(arg);
- argsz += strlen(cmd[i]) + 1;
+ argsz += arglen + 1;
                         i++;
                         a++;
                         leftover = 0;
Received on Sat Mar 28 2015 - 22:03:53 CET

This archive was generated by hypermail 2.3.0 : Sat Mar 28 2015 - 22:12:34 CET