summaryrefslogtreecommitdiffhomepage
path: root/include/stc
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-09-05 18:10:14 +0200
committerTyge Løvset <[email protected]>2023-09-05 18:10:14 +0200
commit493c34e9c2de0587f38681340db8f2735e72d7dd (patch)
tree158838cfe8a4a59d258a9a5817faf2a18808ff38 /include/stc
parent3628e4389ef9455960c42466487385fc228566c3 (diff)
downloadSTC-modified-493c34e9c2de0587f38681340db8f2735e72d7dd.tar.gz
STC-modified-493c34e9c2de0587f38681340db8f2735e72d7dd.zip
Renamed (half)internal functions:
cfasthash() => stc_hash() cstrhash() => stc_strhash() cnextpow2() => stc_nextpow2()
Diffstat (limited to 'include/stc')
-rw-r--r--include/stc/ccommon.h16
-rw-r--r--include/stc/cmap.h2
-rw-r--r--include/stc/crawstr.h4
-rw-r--r--include/stc/cstr.h6
-rw-r--r--include/stc/csview.h6
-rw-r--r--include/stc/priv/cqueue_imp.h2
6 files changed, 18 insertions, 18 deletions
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index 8363fbe5..d074701f 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -103,7 +103,7 @@ typedef long long _llong;
#define c_default_less(x, y) (*(x) < *(y))
#define c_default_eq(x, y) (*(x) == *(y))
#define c_memcmp_eq(x, y) (memcmp(x, y, sizeof *(x)) == 0)
-#define c_default_hash(x) cbytehash(x, c_sizeof(*(x)))
+#define c_default_hash(x) stc_hash(x, c_sizeof(*(x)))
#define c_default_clone(v) (v)
#define c_default_toraw(vp) (*(vp))
@@ -124,7 +124,7 @@ typedef long long _llong;
// Non-owning c-string "class"
typedef const char* ccharptr;
#define ccharptr_cmp(xp, yp) strcmp(*(xp), *(yp))
-#define ccharptr_hash(p) cstrhash(*(p))
+#define ccharptr_hash(p) stc_strhash(*(p))
#define ccharptr_clone(s) (s)
#define ccharptr_drop(p) ((void)p)
@@ -138,7 +138,7 @@ typedef const char* ccharptr;
#define c_ROTL(x, k) (x << (k) | x >> (8*sizeof(x) - (k)))
-STC_INLINE uint64_t cbytehash(const void* key, intptr_t len) {
+STC_INLINE uint64_t stc_hash(const void* key, intptr_t len) {
uint32_t u4; uint64_t u8;
switch (len) {
case 8: memcpy(&u8, key, 8); return u8*0xc6a4a7935bd1e99d;
@@ -156,11 +156,11 @@ STC_INLINE uint64_t cbytehash(const void* key, intptr_t len) {
return h ^ c_ROTL(h, 26);
}
-STC_INLINE uint64_t cstrhash(const char *str)
- { return cbytehash(str, c_strlen(str)); }
+STC_INLINE uint64_t stc_strhash(const char *str)
+ { return stc_hash(str, c_strlen(str)); }
-STC_INLINE char* cstrnstrn(const char *str, const char *needle,
- intptr_t slen, const intptr_t nlen) {
+STC_INLINE char* stc_strnstrn(const char *str, const char *needle,
+ intptr_t slen, const intptr_t nlen) {
if (!nlen) return (char *)str;
if (nlen > slen) return NULL;
slen -= nlen;
@@ -172,7 +172,7 @@ STC_INLINE char* cstrnstrn(const char *str, const char *needle,
return NULL;
}
-STC_INLINE intptr_t cnextpow2(intptr_t n) {
+STC_INLINE intptr_t stc_nextpow2(intptr_t n) {
n--;
n |= n >> 1, n |= n >> 2;
n |= n >> 4, n |= n >> 8;
diff --git a/include/stc/cmap.h b/include/stc/cmap.h
index deee1f59..c069fbd8 100644
--- a/include/stc/cmap.h
+++ b/include/stc/cmap.h
@@ -414,7 +414,7 @@ _cx_MEMB(_reserve)(_cx_Self* self, const intptr_t _newcap) {
if (_newcap != self->size && _newcap <= _oldbucks)
return true;
intptr_t _newbucks = (intptr_t)((float)_newcap / (i_max_load_factor)) + 4;
- _newbucks = cnextpow2(_newbucks);
+ _newbucks = stc_nextpow2(_newbucks);
_cx_Self m = {
(_cx_value *)i_malloc(_newbucks*c_sizeof(_cx_value)),
(struct chash_slot *)i_calloc(_newbucks + 1, c_sizeof(struct chash_slot)),
diff --git a/include/stc/crawstr.h b/include/stc/crawstr.h
index a244397d..9dbdb6f7 100644
--- a/include/stc/crawstr.h
+++ b/include/stc/crawstr.h
@@ -45,7 +45,7 @@ STC_INLINE bool crawstr_equals(crawstr rs, const char* str) {
}
STC_INLINE intptr_t crawstr_find(crawstr rs, const char* search) {
- char* res = cstrnstrn(rs.str, search, rs.size, c_strlen(search));
+ char* res = strstr(rs.str, search);
return res ? (res - rs.str) : c_NPOS;
}
@@ -98,7 +98,7 @@ STC_INLINE bool crawstr_eq(const crawstr* x, const crawstr* y)
{ return x->size == y->size && !c_memcmp(x->str, y->str, x->size); }
STC_INLINE uint64_t crawstr_hash(const crawstr *self)
- { return cbytehash(self->str, self->size); }
+ { return stc_hash(self->str, self->size); }
#endif // CRAWSTR_H_INCLUDED
#undef i_static
diff --git a/include/stc/cstr.h b/include/stc/cstr.h
index 51519d82..d2faeb62 100644
--- a/include/stc/cstr.h
+++ b/include/stc/cstr.h
@@ -450,12 +450,12 @@ bool cstr_valid_utf8(const cstr* self)
STC_DEF uint64_t cstr_hash(const cstr *self) {
csview sv = cstr_sv(self);
- return cbytehash(sv.buf, sv.size);
+ return stc_hash(sv.buf, sv.size);
}
STC_DEF intptr_t cstr_find_sv(const cstr* self, csview search) {
csview sv = cstr_sv(self);
- char* res = cstrnstrn(sv.buf, search.buf, sv.size, search.size);
+ char* res = stc_strnstrn(sv.buf, search.buf, sv.size, search.size);
return res ? (res - sv.buf) : c_NPOS;
}
@@ -588,7 +588,7 @@ STC_DEF cstr cstr_replace_sv(csview in, csview search, csview repl, int32_t coun
intptr_t from = 0; char* res;
if (!count) count = INT32_MAX;
if (search.size)
- while (count-- && (res = cstrnstrn(in.buf + from, search.buf, in.size - from, search.size))) {
+ while (count-- && (res = stc_strnstrn(in.buf + from, search.buf, in.size - from, search.size))) {
const intptr_t pos = (res - in.buf);
cstr_append_n(&out, in.buf + from, pos - from);
cstr_append_n(&out, repl.buf, repl.size);
diff --git a/include/stc/csview.h b/include/stc/csview.h
index 005f27de..f41acf4f 100644
--- a/include/stc/csview.h
+++ b/include/stc/csview.h
@@ -165,12 +165,12 @@ STC_DEF csview_iter csview_advance(csview_iter it, intptr_t pos) {
}
STC_DEF intptr_t csview_find_sv(csview sv, csview search) {
- char* res = cstrnstrn(sv.buf, search.buf, sv.size, search.size);
+ char* res = stc_strnstrn(sv.buf, search.buf, sv.size, search.size);
return res ? (res - sv.buf) : c_NPOS;
}
STC_DEF uint64_t csview_hash(const csview *self)
- { return cbytehash(self->buf, self->size); }
+ { return stc_hash(self->buf, self->size); }
STC_DEF csview csview_substr_ex(csview sv, intptr_t pos, intptr_t n) {
if (pos < 0) {
@@ -197,7 +197,7 @@ STC_DEF csview csview_slice_ex(csview sv, intptr_t p1, intptr_t p2) {
STC_DEF csview csview_token(csview sv, const char* sep, intptr_t* start) {
intptr_t sep_size = c_strlen(sep);
csview slice = {sv.buf + *start, sv.size - *start};
- const char* res = cstrnstrn(slice.buf, sep, slice.size, sep_size);
+ const char* res = stc_strnstrn(slice.buf, sep, slice.size, sep_size);
csview tok = {slice.buf, res ? (res - slice.buf) : slice.size};
*start += tok.size + sep_size;
return tok;
diff --git a/include/stc/priv/cqueue_imp.h b/include/stc/priv/cqueue_imp.h
index 2ad9c811..18c1bb15 100644
--- a/include/stc/priv/cqueue_imp.h
+++ b/include/stc/priv/cqueue_imp.h
@@ -54,7 +54,7 @@ STC_DEF bool
_cx_MEMB(_reserve)(_cx_Self* self, const intptr_t n) {
if (n <= self->capmask)
return true;
- intptr_t oldcap = self->capmask + 1, newcap = cnextpow2(n + 1);
+ intptr_t oldcap = self->capmask + 1, newcap = stc_nextpow2(n + 1);
_cx_value* d = (_cx_value *)i_realloc(self->data, newcap*c_sizeof *self->data);
if (!d)
return false;