diff options
author | Mark Salyzyn | 2016-12-02 12:08:48 -0600 |
---|---|---|
committer | Mark Salyzyn | 2016-12-09 14:40:17 -0600 |
commit | 0eeb06b932f185e10377e4494475d2cdd6adfa1b (patch) | |
tree | 70b797c0f3f752a6a76e9818640b1fadf06ca189 /logd/LogUtils.h | |
parent | aece425166b1636de79efbddb5997ecdcea2ce03 (diff) | |
download | platform-system-core-0eeb06b932f185e10377e4494475d2cdd6adfa1b.tar.gz platform-system-core-0eeb06b932f185e10377e4494475d2cdd6adfa1b.tar.xz platform-system-core-0eeb06b932f185e10377e4494475d2cdd6adfa1b.zip |
utils: Add FastStrcmp.h
Move existing fast<str*cmp> templates for general use, pulled from
the implementation used in logd that dealt with speed through cache
locality and subroutine call mitigation. Rename to fastcmp.
Test: logd-benchmarks and based on manual profiling from the past
Bug: 31456426
Change-Id: Ic62f4a437fc3e06ffdeaae73a6f34e197957a6b0
Diffstat (limited to 'logd/LogUtils.h')
-rw-r--r-- | logd/LogUtils.h | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/logd/LogUtils.h b/logd/LogUtils.h index 44ac742f0..ec6806225 100644 --- a/logd/LogUtils.h +++ b/logd/LogUtils.h | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <sys/cdefs.h> | 20 | #include <sys/cdefs.h> |
21 | #include <sys/types.h> | 21 | #include <sys/types.h> |
22 | 22 | ||
23 | #include <utils/FastStrcmp.h> | ||
23 | #include <private/android_logger.h> | 24 | #include <private/android_logger.h> |
24 | #include <sysutils/SocketClient.h> | 25 | #include <sysutils/SocketClient.h> |
25 | 26 | ||
@@ -50,21 +51,4 @@ static inline bool worstUidEnabledForLogid(log_id_t id) { | |||
50 | (id == LOG_ID_RADIO) || (id == LOG_ID_EVENTS); | 51 | (id == LOG_ID_RADIO) || (id == LOG_ID_EVENTS); |
51 | } | 52 | } |
52 | 53 | ||
53 | template <int (*cmp)(const char *l, const char *r, const size_t s)> | ||
54 | static inline int fast(const char *l, const char *r, const size_t s) { | ||
55 | return (*l != *r) || cmp(l + 1, r + 1, s - 1); | ||
56 | } | ||
57 | |||
58 | template <int (*cmp)(const void *l, const void *r, const size_t s)> | ||
59 | static inline int fast(const void *lv, const void *rv, const size_t s) { | ||
60 | const char *l = static_cast<const char *>(lv); | ||
61 | const char *r = static_cast<const char *>(rv); | ||
62 | return (*l != *r) || cmp(l + 1, r + 1, s - 1); | ||
63 | } | ||
64 | |||
65 | template <int (*cmp)(const char *l, const char *r)> | ||
66 | static inline int fast(const char *l, const char *r) { | ||
67 | return (*l != *r) || cmp(l + 1, r + 1); | ||
68 | } | ||
69 | |||
70 | #endif // _LOGD_LOG_UTILS_H__ | 54 | #endif // _LOGD_LOG_UTILS_H__ |