From a506e844d169350a3ac4998c79b3c441fd5ef7bd Mon Sep 17 00:00:00 2001 From: ache Date: Sun, 3 Aug 2003 22:19:43 +0000 Subject: [PATCH] Microoptimization of prev. patch: do strdup() only if (cflag || Cflag) --- usr.bin/tr/tr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/usr.bin/tr/tr.c b/usr.bin/tr/tr.c index b5d6d2089036..91c0e9c9ab3f 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");