summaryrefslogtreecommitdiff
path: root/wsutil/ws_mempbrk.h
diff options
context:
space:
mode:
authorHadriel Kaplan <hadrielk@yahoo.com>2015-02-06 13:52:37 -0500
committerAnders Broman <a.broman58@gmail.com>2015-02-11 09:14:50 +0000
commita837570d02dca2ad94ff5046b13592d84a12a345 (patch)
tree0a06b1d9a1c7c1e6bc67f57412f7adc3a2a1db71 /wsutil/ws_mempbrk.h
parenta618f1c0d63fd290cbdc93272beaf1ca7e838027 (diff)
downloadwireshark-a837570d02dca2ad94ff5046b13592d84a12a345.tar.gz
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 'wsutil/ws_mempbrk.h')
-rw-r--r--wsutil/ws_mempbrk.h27
1 files changed, 22 insertions, 5 deletions
diff --git a/wsutil/ws_mempbrk.h b/wsutil/ws_mempbrk.h
index 72f37d574a..708d53cfff 100644
--- a/wsutil/ws_mempbrk.h
+++ b/wsutil/ws_mempbrk.h
@@ -24,13 +24,30 @@
#include "ws_symbol_export.h"
-WS_DLL_PUBLIC const guint8 *ws_mempbrk(const guint8* haystack, size_t haystacklen, const guint8 *needles);
+/** The pattern object used for tvb_pbrk_pattern_guint8().
+ */
+typedef struct {
+ gchar patt[256];
+ gboolean use_sse42;
+ void *mask;
+} tvb_pbrk_pattern;
+
+/** The value to use when initializing a tvb_pbrk_pattern variable.
+ * For example:
+ * static tvb_pbrk_pattern pbrk_mypattern = INIT_PBRK_PATTERN;
+ */
+#define INIT_PBRK_PATTERN { { 0 }, FALSE, NULL }
+
+/** Compile the pattern for the needles to find using tvb_pbrk_pattern_guint8().
+ */
+WS_DLL_PUBLIC void tvb_pbrk_compile(tvb_pbrk_pattern* pattern, const gchar *needles);
+
+WS_DLL_PUBLIC const guint8 *tvb_pbrk_exec(const guint8* haystack, size_t haystacklen, const tvb_pbrk_pattern* pattern, guchar *found_needle);
-#ifdef HAVE_SSE4_2
-const char *_ws_mempbrk_sse42(const char* haystack, size_t haystacklen, const char *needles);
-#endif
+void ws_mempbrk_sse42_compile(tvb_pbrk_pattern* pattern, const gchar *needles);
+const char *ws_mempbrk_sse42_exec(const char* haystack, size_t haystacklen, const tvb_pbrk_pattern* pattern, guchar *found_needle);
-const guint8 *_ws_mempbrk(const guint8* haystack, size_t haystacklen, const guint8 *needles);
+const guint8 *ws_mempbrk_exec(const guint8* haystack, size_t haystacklen, const tvb_pbrk_pattern* pattern, guchar *found_needle);
#endif /* __WS_MEMPBRK_H__ */