diff options
author | Jakub Zawadzki <darkjames@darkjames.pl> | 2014-05-22 23:04:40 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2014-06-09 12:02:27 +0000 |
commit | fcb710baec3caa30c2cb7c444bddbe087fc86574 (patch) | |
tree | 1ff3f1c4d9b5dca0794162a1000bede1b3a128e6 /epan | |
parent | 66695661992beb054eff219dd73a23559220c867 (diff) |
Add sse4.2 optimized function ws_mempbrk_sse42()
In text protocols, like SIP, lot of time is spend guint8_pbrk(),
assume that text is not binary (no NULs), and use SSE4.2 pcmpistri
instruction.
Also move & rename guint8_pbrk() from tvbuff.c as _ws_mempbrk.
HAVE_SSE42 must be defined to use _ws_mempbrk_sse42() only activaded for
Windows currently.
Change-Id: Ic853d84805bdb6492c4f45d2bcc79a973fd9804e
Reviewed-on: https://code.wireshark.org/review/1730
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/tvbuff.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c index be7f1403e5..a286924053 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -739,26 +739,17 @@ fast_ensure_contiguous(tvbuff_t *tvb, const gint offset, const guint length) return NULL; } +extern const guint8 *ws_mempbrk(const guint8* haystack, size_t haystacklen, const guint8 *needles); + static inline const guint8* guint8_pbrk(const guint8* haystack, size_t haystacklen, const guint8 *needles, guchar *found_needle) { - gchar tmp[256] = { 0 }; - const guint8 *haystack_end; - - while (*needles) - tmp[*needles++] = 1; + const guint8 *result = ws_mempbrk(haystack, haystacklen, needles); - haystack_end = haystack + haystacklen; - while (haystack < haystack_end) { - if (tmp[*haystack]) { - if (found_needle) - *found_needle = *haystack; - return haystack; - } - haystack++; - } + if (result && found_needle) + *found_needle = *result; - return NULL; + return result; } @@ -2963,6 +2954,12 @@ tvb_get_nstringz0(tvbuff_t *tvb, const gint offset, const guint bufsize, guint8* gint tvb_find_line_end(tvbuff_t *tvb, const gint offset, int len, gint *next_offset, const gboolean desegment) { +#ifdef WIN32 + static const char __declspec(align(16)) crlf[] = "\r\n" ; +#else + static const char crlf[] __attribute__((aligned(16))) = "\r\n" ; +#endif + gint eob_offset; gint eol_offset; int linelen; @@ -2981,7 +2978,7 @@ tvb_find_line_end(tvbuff_t *tvb, const gint offset, int len, gint *next_offset, /* * Look either for a CR or an LF. */ - eol_offset = tvb_pbrk_guint8(tvb, offset, len, "\r\n", &found_needle); + eol_offset = tvb_pbrk_guint8(tvb, offset, len, crlf, &found_needle); if (eol_offset == -1) { /* * No CR or LF - line is presumably continued in next packet. |