Optimize iocb_cmd_lookup
* desc.c (iocb_cmd_lookup): Make command table constant.
Reduce size of static char buffer.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
diff --git a/desc.c b/desc.c
index 9e06b30..00bf37b 100644
--- a/desc.c
+++ b/desc.c
@@ -823,8 +823,8 @@
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 @@
return cmds[cmd].name;
}
*sub = SUB_NONE;
- snprintf(buf, sizeof(buf), "%u /* SUB_??? */", cmd);
+ sprintf(buf, "%u /* SUB_??? */", cmd);
return buf;
}