diff options
author | Anders Broman <anders.broman@ericsson.com> | 2010-04-28 07:58:59 +0000 |
---|---|---|
committer | Anders Broman <anders.broman@ericsson.com> | 2010-04-28 07:58:59 +0000 |
commit | 4a711cc74a3954dbe0af2ec46db8d10bc2f2d187 (patch) | |
tree | 94acf7277474eabb18fe363bac693447250d2ee7 /epan/tvbuff.c | |
parent | 863b392200a6069efcb08a90acd9ecab341a692d (diff) |
From Jakub Zawadzki:
- optimize guint8_pbrk().
svn path=/trunk/; revision=32583
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r-- | epan/tvbuff.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c index 8ecc1b9865..65100f27b3 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -972,22 +972,20 @@ guint8_find(const guint8* haystack, const size_t haystacklen, const guint8 needl static const guint8* guint8_pbrk(const guint8* haystack, size_t haystacklen, const guint8 *needles, guchar *found_needle) { - const guint8 *b; - int i; - guint8 item, needle; - const guint8 *needlep; - - for (b = haystack, i = 0; (guint) i < haystacklen; i++, b++) { - item = *b; - needlep = needles; - while ((needle = *needlep) != '\0') { - if (item == needle){ - if(found_needle) - *found_needle = needle; - return b; - } - needlep++; + gchar tmp[256] = { 0 }; + const guint8 *haystack_end; + + while (*needles) + tmp[*needles++] = 1; + + haystack_end = haystack + haystacklen; + while (haystack < haystack_end) { + if (tmp[*haystack]) { + if(found_needle) + *found_needle = *haystack; + return haystack; } + haystack++; } return NULL; |