mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
- wcsstr() is now linearly complex - strstr16() is now linearly complex - strstr() is now vectorized on aarch64 (10x) - strstr() now uses KMP on pathological cases - memmem() is now vectorized on aarch64 (10x) - memmem() now uses KMP on pathological cases - Disable shared_ptr::owner_before until fixed - Make iswlower(), iswupper() consistent with glibc - Remove figure space from iswspace() implementation - Include line and paragraph separator in iswcntrl() - Use Musl wcwidth(), iswalpha(), iswpunct(), towlower(), towupper()
24 lines
543 B
C++
24 lines
543 B
C++
// -*- c++ -*-
|
|
#ifndef COSMOPOLITAN_LIBC_STR_HAS_CHAR_H_
|
|
#define COSMOPOLITAN_LIBC_STR_HAS_CHAR_H_
|
|
#ifdef __cplusplus
|
|
|
|
template <typename T>
|
|
static bool has_char(const T (*ranges)[2], size_t n, T c) {
|
|
unsigned l = 0;
|
|
unsigned r = n;
|
|
while (l < r) {
|
|
unsigned m = (l & r) + ((l ^ r) >> 1); // floor((a+b)/2)
|
|
if (c < ranges[m][0]) {
|
|
r = m;
|
|
} else if (c > ranges[m][1]) {
|
|
l = m + 1;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
#endif /* COSMOPOLITAN_LIBC_STR_HAS_CHAR_H_ */
|