aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAndré Goddard Rosa <andre.goddard@gmail.com>2009-12-14 21:01:08 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-15 11:53:33 -0500
commitb5f54b07c06f6e438a4fee92c27423e880d8816b (patch)
treed1bac8b28c77f1b646dde9779eba73d927d269f7 /lib
parente7d2860b690d4f3bed6824757c540579638e3d1e (diff)
parser: remove unnecessary strlen()
No functional change. Cache strlen() result to avoid recalculating it up to 3 times on the worst case. Reduces code size a little by 32 bytes: text data bss dec hex filename 1385 0 0 1385 569 lib/parser.o-BEFORE 1353 0 0 1353 549 lib/parser.o-AFTER Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com> Cc: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/parser.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/parser.c b/lib/parser.c
index b00d02059a5f..fb34977246bb 100644
--- a/lib/parser.c
+++ b/lib/parser.c
@@ -56,13 +56,16 @@ static int match_one(char *s, const char *p, substring_t args[])
56 56
57 args[argc].from = s; 57 args[argc].from = s;
58 switch (*p++) { 58 switch (*p++) {
59 case 's': 59 case 's': {
60 if (strlen(s) == 0) 60 size_t str_len = strlen(s);
61
62 if (str_len == 0)
61 return 0; 63 return 0;
62 else if (len == -1 || len > strlen(s)) 64 if (len == -1 || len > str_len)
63 len = strlen(s); 65 len = str_len;
64 args[argc].to = s + len; 66 args[argc].to = s + len;
65 break; 67 break;
68 }
66 case 'd': 69 case 'd':
67 simple_strtol(s, &args[argc].to, 0); 70 simple_strtol(s, &args[argc].to, 0);
68 goto num; 71 goto num;