summaryrefslogtreecommitdiffhomepage
path: root/stc
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-01-09 23:55:42 +0100
committerTyge Løvset <[email protected]>2021-01-09 23:55:42 +0100
commitf504699fb346eeb37b2ea2afe493566a26be7f4e (patch)
tree037a22aa785f8a4a977e2546a89cd3eccd38f726 /stc
parent0b64431209cb7acf86f4db055e69e23b7a9d8ef6 (diff)
downloadSTC-modified-f504699fb346eeb37b2ea2afe493566a26be7f4e.tar.gz
STC-modified-f504699fb346eeb37b2ea2afe493566a26be7f4e.zip
Added cmap benchmark and external picobenchmark.hpp
Updated cstr.h
Diffstat (limited to 'stc')
-rw-r--r--stc/cstr.h19
1 files changed, 9 insertions, 10 deletions
diff --git a/stc/cstr.h b/stc/cstr.h
index 32b2eb52..94714d02 100644
--- a/stc/cstr.h
+++ b/stc/cstr.h
@@ -201,10 +201,6 @@ STC_INLINE bool
cstr_equals_s(cstr_t s1, cstr_t s2) {
return strcmp(s1.str, s2.str) == 0;
}
-STC_INLINE int
-cstr_compare(const cstr_t *s1, const cstr_t *s2) {
- return strcmp(s1->str, s2->str);
-}
STC_INLINE bool
cstr_contains(cstr_t s, const char* needle) {
@@ -237,20 +233,23 @@ cstr_iends_with(cstr_t s, const char* needle) {
/* cvec/cmap API functions: */
-#define cstr_to_raw(x) ((x)->str)
-#define cstr_compare_raw(x, y) strcmp(*(x), *(y))
-#define cstr_equals_raw(x, y) (strcmp(*(x), *(y)) == 0)
-
STC_INLINE uint32_t c_string_hash(const char* str) {
uint32_t hash = 5381, c; /* djb2 */
while ((c = *str++)) hash = ((hash << 5) + hash) ^ c;
return hash;
}
-STC_INLINE uint32_t cstr_hash_raw(const char* const* strref, size_t ignored) {
- return c_string_hash(*strref);
+STC_INLINE uint32_t cstr_hash_raw(const char* const* ptrref, size_t ignored) {
+ return c_string_hash(*ptrref);
}
+#define cstr_to_raw(x) ((x)->str)
+#define cstr_compare_raw(x, y) strcmp(*(x), *(y))
+#define cstr_equals_raw(x, y) (strcmp(*(x), *(y)) == 0)
+#define cstr_compare_ref(x, y) strcmp((x)->str, (y)->str)
+#define cstr_equals_ref(x, y) (strcmp((x)->str, (y)->str) == 0)
+#define cstr_hash_ref(x, none) c_string_hash((x)->str)
+
/* -------------------------- IMPLEMENTATION ------------------------- */
#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION)