]> granicus.if.org Git - strace/commitdiff
Optimize iocb_cmd_lookup
authorDenys Vlasenko <dvlasenk@redhat.com>
Fri, 19 Aug 2011 17:44:17 +0000 (19:44 +0200)
committerDenys Vlasenko <dvlasenk@redhat.com>
Tue, 23 Aug 2011 10:53:01 +0000 (12:53 +0200)
* desc.c (iocb_cmd_lookup): Make command table constant.
Reduce size of static char buffer.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
desc.c

diff --git a/desc.c b/desc.c
index 9e06b30457c174868c4a49433c49eeac0910f5ca..00bf37bfe584517b4da9eee51217150eb116578c 100644 (file)
--- a/desc.c
+++ b/desc.c
@@ -823,8 +823,8 @@ enum iocb_sub {
 static const char *
 iocb_cmd_lookup(unsigned cmd, enum iocb_sub *sub)
 {
-       static char buf[64];
-       static struct {
+       static char buf[sizeof("%u /* SUB_??? */") + sizeof(int)*3];
+       static const struct {
                const char *name;
                enum iocb_sub sub;
        } cmds[] = {
@@ -844,7 +844,7 @@ iocb_cmd_lookup(unsigned cmd, enum iocb_sub *sub)
                return cmds[cmd].name;
        }
        *sub = SUB_NONE;
-       snprintf(buf, sizeof(buf), "%u /* SUB_??? */", cmd);
+       sprintf(buf, "%u /* SUB_??? */", cmd);
        return buf;
 }