aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorMartin Mathieson <martin.mathieson@keysight.com>2020-11-07 22:11:21 +0000
committerAndersBroman <a.broman58@gmail.com>2020-11-10 05:54:54 +0000
commit07f048f1f20da206276a1f7240c8d0650582e522 (patch)
treed9a90a2d10159d378769f64a92a7b24cc23eb97d /epan
parentdfa8a3fe5a1408a4355bb325d358dd1ab2c27d31 (diff)
parsing enterprises file: comment and slightly simplify
This is roughly 10% of tshark startup time. - Enterprise string does not need to be trimmed at the beginning - No need to call g_hash_table_replace() as keys are just guint32
Diffstat (limited to 'epan')
-rw-r--r--epan/addr_resolv.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c
index 478b328bf9..f51f810ec7 100644
--- a/epan/addr_resolv.c
+++ b/epan/addr_resolv.c
@@ -857,20 +857,30 @@ parse_enterprises_line (char *line)
{
char *tok, *dec_str, *org_str;
guint32 dec;
+ gboolean had_comment = FALSE;
- if ((tok = strchr(line, '#')))
+ /* Stop the line at any comment found */
+ if ((tok = strchr(line, '#'))) {
*tok = '\0';
+ had_comment = TRUE;
+ }
+ /* Get enterprise number */
dec_str = strtok(line, " \t");
if (!dec_str)
return;
+ /* Get enterprise name */
org_str = strtok(NULL, ""); /* everything else */
- if (org_str)
- org_str = g_strstrip(org_str);
+ if (org_str && had_comment) {
+ /* Only need to strip after (between name and where comment was) */
+ org_str = g_strchomp(org_str);
+ }
if (!org_str)
return;
+
+ /* Add entry using number as key */
if (!ws_strtou32(dec_str, NULL, &dec))
return;
- g_hash_table_replace(enterprises_hashtable, GUINT_TO_POINTER(dec), g_strdup(org_str));
+ g_hash_table_insert(enterprises_hashtable, GUINT_TO_POINTER(dec), g_strdup(org_str));
}