diff options
author | Hadriel Kaplan <hadrielk@yahoo.com> | 2015-02-06 13:52:37 -0500 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2015-02-11 09:14:50 +0000 |
commit | a837570d02dca2ad94ff5046b13592d84a12a345 (patch) | |
tree | 0a06b1d9a1c7c1e6bc67f57412f7adc3a2a1db71 /epan/dissectors/packet-megaco.c | |
parent | a618f1c0d63fd290cbdc93272beaf1ca7e838027 (diff) |
Combine SSE and pre-compiled patterns for faster pbrk
This combines the SSE4.2 instructions usage, with pre-compiled
pattern searching usage, for a faster pbrk search method.
Testing against large files of HTTP and SIP, there is about
a 5% performance improvement by using pre-"compiled" patterns
for guint8_pbrk() instead of passing it the search string and
having it build the match array every time.
Similar to regular expressions, "compiling" the pattern match array
in advance only once and using the "compiled" patterns for
the searches is faster than compiling it every time.
Change-Id: Ifcbc14a6c93f32d15663a10d974bacdca5119a8e
Ping-Bug: 10798
Reviewed-on: https://code.wireshark.org/review/6990
Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-megaco.c')
-rw-r--r-- | epan/dissectors/packet-megaco.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/epan/dissectors/packet-megaco.c b/epan/dissectors/packet-megaco.c index b80ed25505..84bd157f56 100644 --- a/epan/dissectors/packet-megaco.c +++ b/epan/dissectors/packet-megaco.c @@ -139,6 +139,11 @@ static dissector_handle_t megaco_text_handle; static int megaco_tap = -1; +/* patterns used for tvb_pbrk_pattern_guint8 */ +static tvb_pbrk_pattern pbrk_whitespace = INIT_PBRK_PATTERN; +static tvb_pbrk_pattern pbrk_braces = INIT_PBRK_PATTERN; + + /* * Here are the global variables associated with * the various user definable characteristics of the dissection @@ -451,7 +456,7 @@ dissect_megaco_text(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) * pathNAME = ["*"] NAME *("/" / "*"/ ALPHA / DIGIT /"_" / "$" )["@" pathDomainName ] */ - tvb_current_offset = tvb_pbrk_guint8(tvb, tvb_current_offset, -1, " \t\r\n", &needle); + tvb_current_offset = tvb_pbrk_pattern_guint8(tvb, tvb_current_offset, -1, &pbrk_whitespace, &needle); if (tvb_current_offset == -1) { expert_add_info_format(pinfo, ti, &ei_megaco_parse_error, "[ Parse error: no body in MEGACO message (missing SEP after mId) ]"); @@ -3284,7 +3289,7 @@ static gint megaco_tvb_find_token(tvbuff_t* tvb, gint offset, gint maxlength){ guchar needle; do { - pos = tvb_pbrk_guint8(tvb, pos + 1, maxlength, "{}", &needle); + pos = tvb_pbrk_pattern_guint8(tvb, pos + 1, maxlength, &pbrk_braces, &needle); if(pos == -1) return -1; switch(needle){ @@ -3564,6 +3569,10 @@ proto_register_megaco(void) megaco_tap = register_tap("megaco"); + /* compile patterns */ + tvb_pbrk_compile(&pbrk_whitespace, " \t\r\n"); + tvb_pbrk_compile(&pbrk_braces, "{}"); + } /* Register all the bits needed with the filtering engine */ |