aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-04-07 14:56:18 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-04-07 15:05:07 +0100
commit14a87a3aeb18825883a69f89ba310c526a950762 (patch)
tree179cea5fd8540cd5f6c36a64fb8a4d83d77f05e5 /src/libutil
parent8d535feef2e2a2c7d1a085cd990d6e321313da9e (diff)
downloadrspamd-14a87a3aeb18825883a69f89ba310c526a950762.tar.gz
rspamd-14a87a3aeb18825883a69f89ba310c526a950762.zip
[Minor] Fix inline issues
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/str_util.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/libutil/str_util.c b/src/libutil/str_util.c
index b84d3e5f3..f3e4a1f8c 100644
--- a/src/libutil/str_util.c
+++ b/src/libutil/str_util.c
@@ -1191,7 +1191,7 @@ static inline bool rspamd_substring_casecmp_func (guchar a, guchar b) { return l
typedef bool (*rspamd_cmpchar_func_t) (guchar a, guchar b);
static inline void
-rspamd_substring_preprocess (const gchar *pat, gsize len, goffset *fsm,
+rspamd_substring_preprocess_kmp (const gchar *pat, gsize len, goffset *fsm,
rspamd_cmpchar_func_t f)
{
goffset i, j;
@@ -1217,21 +1217,22 @@ rspamd_substring_preprocess (const gchar *pat, gsize len, goffset *fsm,
}
}
-static goffset
-rspamd_substring_seacrh_common (const gchar *in, gsize inlen,
+static inline goffset
+rspamd_substring_search_common (const gchar *in, gsize inlen,
const gchar *srch, gsize srchlen, rspamd_cmpchar_func_t f)
{
+ static goffset st_fsm[128];
goffset *fsm;
goffset i, j, k, ell, ret = -1;
- if (G_LIKELY (srchlen < 1024)) {
- fsm = g_alloca ((srchlen + 1) * sizeof (*fsm));
+ if (G_LIKELY (srchlen < G_N_ELEMENTS (st_fsm))) {
+ fsm = st_fsm;
}
else {
fsm = g_malloc ((srchlen + 1) * sizeof (*fsm));
}
- rspamd_substring_preprocess (srch, srchlen, fsm, f);
+ rspamd_substring_preprocess_kmp (srch, srchlen, fsm, f);
for (ell = 1; f(srch[ell - 1], srch[ell]); ell++) {}
if (ell == srchlen) {
@@ -1275,7 +1276,7 @@ rspamd_substring_seacrh_common (const gchar *in, gsize inlen,
}
out:
- if (G_UNLIKELY (srchlen >= 1024)) {
+ if (G_UNLIKELY (srchlen >= G_N_ELEMENTS (st_fsm))) {
g_free (fsm);
}
@@ -1287,7 +1288,7 @@ rspamd_substring_search (const gchar *in, gsize inlen,
const gchar *srch, gsize srchlen)
{
if (inlen > srchlen) {
- return rspamd_substring_seacrh_common (in, inlen, srch, srchlen,
+ return rspamd_substring_search_common (in, inlen, srch, srchlen,
rspamd_substring_cmp_func);
}
else if (inlen == srchlen) {
@@ -1305,7 +1306,7 @@ rspamd_substring_search_caseless (const gchar *in, gsize inlen,
const gchar *srch, gsize srchlen)
{
if (inlen > srchlen) {
- return rspamd_substring_seacrh_common (in, inlen, srch, srchlen,
+ return rspamd_substring_search_common (in, inlen, srch, srchlen,
rspamd_substring_casecmp_func);
}
else if (inlen == srchlen) {