diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-01-27 18:05:15 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-01-27 18:05:15 +0000 |
commit | cec3e89b046705b1ce488626ad059ce4b4ea9b6b (patch) | |
tree | 7e5f82705cbf7a90e07fb743ffa9e375c56c76e8 /src/libutil/str_util.h | |
parent | a4d2691a85bfa567cc9afe2b97fe2ae4a04a2fde (diff) | |
download | rspamd-cec3e89b046705b1ce488626ad059ce4b4ea9b6b.tar.gz rspamd-cec3e89b046705b1ce488626ad059ce4b4ea9b6b.zip |
[Feature] Speed up is_ascii function
Diffstat (limited to 'src/libutil/str_util.h')
-rw-r--r-- | src/libutil/str_util.h | 34 |
1 files changed, 1 insertions, 33 deletions
diff --git a/src/libutil/str_util.h b/src/libutil/str_util.h index c08dd55bb..22643176b 100644 --- a/src/libutil/str_util.h +++ b/src/libutil/str_util.h @@ -440,39 +440,7 @@ gsize rspamd_memspn (const gchar *s, const gchar *e, gsize len); */ #define rspamd_is_aligned(p, n) (((uintptr_t)(p) & ((uintptr_t)(n) - 1)) == 0) #define rspamd_is_aligned_as(p, v) rspamd_is_aligned(p, _Alignof(__typeof((v)))) - -static inline gboolean -rspamd_str_has_8bit (const guchar *beg, gsize len) -{ - unsigned long *w; - gsize i, leftover; - - if (rspamd_is_aligned_as (beg, *w)) { - leftover = len % sizeof (*w); - w = (unsigned long *) beg; - - for (i = 0; i < len / sizeof (*w); i++) { - if (rspamd_str_hasmore (*w, 127)) { - return TRUE; - } - - w++; - } - - beg = (const guchar *) w; - } - else { - leftover = len; - } - - for (i = 0; i < leftover; i++) { - if (beg[i] > 127) { - return TRUE; - } - } - - return FALSE; -} +gboolean rspamd_str_has_8bit (const guchar *beg, gsize len); struct UConverter; |