diff options
author | ache <ache@FreeBSD.org> | 2003-08-03 22:19:43 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2003-08-03 22:19:43 +0000 |
commit | a506e844d169350a3ac4998c79b3c441fd5ef7bd (patch) | |
tree | dc79871bbe66e9f9c58be2c6c5e7ec9e23531cac /usr.bin | |
parent | a6e89181546a5545fb9cac0b700e9675521e1741 (diff) | |
download | FreeBSD-src-a506e844d169350a3ac4998c79b3c441fd5ef7bd.zip FreeBSD-src-a506e844d169350a3ac4998c79b3c441fd5ef7bd.tar.gz |
Microoptimization of prev. patch: do strdup() only if (cflag || Cflag)
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tr/tr.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/tr/tr.c b/usr.bin/tr/tr.c index b5d6d20..91c0e9c 100644 --- a/usr.bin/tr/tr.c +++ b/usr.bin/tr/tr.c @@ -214,12 +214,14 @@ main(int argc, char **argv) usage(); s1.str = argv[0]; - if ((s2.str = strdup(argv[1])) == NULL) - errx(2, "strdup(argv[1])"); + if (cflag || Cflag) { + if ((s2.str = strdup(argv[1])) == NULL) + errx(1, "strdup(argv[1])"); - if (cflag || Cflag) for (cnt = NCHARS, p = string1; cnt--;) *p++ = OOBCH; + } else + s2.str = argv[1]; if (!next(&s2)) errx(1, "empty string2"); |