diff options
author | Bill Meier <wmeier@newsguy.com> | 2013-06-30 23:03:20 +0000 |
---|---|---|
committer | Bill Meier <wmeier@newsguy.com> | 2013-06-30 23:03:20 +0000 |
commit | 6499394c780c80b92e73498f13ce9b4a624df437 (patch) | |
tree | 86f5433f9238a047feea71e36db775474b347c74 /epan/column.c | |
parent | 5bbc26236a162815e52e148b239da5366344062c (diff) |
Declare slist[] as static (reduces storage & code executed: *See below);
Declare dlist[] similarly to slist[] (not really needed since generated storage/code was OK as is)
*On Windows the following program generates sub-optimal code
(when built using VC10 or VC11 with CFLAGS as used when building Wireshark).
void foo(void) {
const char *const zz[] = {"ABC", "abc"};
}
-------------
Code generated:
<snip>
_DATA SEGMENT
$SG1013 DB 'ABC', 00H !!! note string stored twice !!
$SG1014 DB 'ABC', 00H
$SG1015 DB 'abc', 00H
$SG1016 DB 'abc', 00H
_DATA ENDS
<snip>
; 1 : void foo(void) {
push ebp
mov ebp, esp
sub esp, 8
; 2 : const char *const zz[] = {"ABC", "abc"};
mov DWORD PTR _zz$[ebp], OFFSET $SG1014 !! note: each ptr of array
mov DWORD PTR _zz$[ebp+4], OFFSET $SG1016 !! individually pushed on stack
<snip>
Not shown: Declaring zz as 'static' generates much better code....
svn path=/trunk/; revision=50271
Diffstat (limited to 'epan/column.c')
-rw-r--r-- | epan/column.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/epan/column.c b/epan/column.c index e25252b54c..cef7241778 100644 --- a/epan/column.c +++ b/epan/column.c @@ -43,7 +43,7 @@ string */ const gchar * col_format_to_string(const gint fmt) { - const gchar *slist[] = { + static const gchar *const slist[NUM_COL_FMTS] = { "%q", /* 0) COL_8021Q_VLAN_ID */ "%Yt", /* 1) COL_ABS_DATE_TIME */ "%At", /* 2) COL_ABS_TIME */ @@ -115,7 +115,9 @@ col_format_to_string(const gint fmt) { /* Given a format number (as defined in column_info.h), returns its description */ -static const gchar *dlist[NUM_COL_FMTS] = { +const gchar * +col_format_desc(const gint fmt) { + static const gchar *const dlist[NUM_COL_FMTS] = { "802.1Q VLAN id", /* 0) COL_8021Q_VLAN_ID */ "Absolute date and time", /* 1) COL_ABS_DATE_TIME */ "Absolute time", /* 2) COL_ABS_TIME */ @@ -177,10 +179,8 @@ static const gchar *dlist[NUM_COL_FMTS] = { "UTC date and time", /* 58) COL_UTC_DATE_TIME */ "UTC time", /* 59) COL_UTC_TIME */ "Time (format as specified)" /* 60) COL_CLS_TIME */ -}; + }; -const gchar * -col_format_desc(const gint fmt) { g_assert((fmt >= 0) && (fmt < NUM_COL_FMTS)); return(dlist[fmt]); } |