diff options
Diffstat (limited to 'logd/LogUtils.h')
-rw-r--r-- | logd/LogUtils.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/logd/LogUtils.h b/logd/LogUtils.h index 117bc59..533eb1c 100644 --- a/logd/LogUtils.h +++ b/logd/LogUtils.h @@ -42,4 +42,21 @@ static inline bool worstUidEnabledForLogid(log_id_t id) { return (id != LOG_ID_CRASH) && (id != LOG_ID_KERNEL) && (id != LOG_ID_EVENTS); } +template <int (*cmp)(const char *l, const char *r, const size_t s)> +static inline int fast(const char *l, const char *r, const size_t s) { + return (*l != *r) || cmp(l + 1, r + 1, s - 1); +} + +template <int (*cmp)(const void *l, const void *r, const size_t s)> +static inline int fast(const void *lv, const void *rv, const size_t s) { + const char *l = static_cast<const char *>(lv); + const char *r = static_cast<const char *>(rv); + return (*l != *r) || cmp(l + 1, r + 1, s - 1); +} + +template <int (*cmp)(const char *l, const char *r)> +static inline int fast(const char *l, const char *r) { + return (*l != *r) || cmp(l + 1, r + 1); +} + #endif // _LOGD_LOG_UTILS_H__ |