From: Denys Vlasenko Date: Fri, 19 Aug 2011 17:44:17 +0000 (+0200) Subject: Optimize iocb_cmd_lookup X-Git-Tag: v4.7~321 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=799926211a0343561a92d8fc6dfc87202a136bd0;p=strace Optimize iocb_cmd_lookup * desc.c (iocb_cmd_lookup): Make command table constant. Reduce size of static char buffer. Signed-off-by: Denys Vlasenko --- diff --git a/desc.c b/desc.c index 9e06b304..00bf37bf 100644 --- 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; }