mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-03 17:58:30 +00:00
Make improvements
- 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()
This commit is contained in:
parent
e1528a71e2
commit
7c83f4abc8
67 changed files with 5602 additions and 5165 deletions
24
libc/str/has_char.h
Normal file
24
libc/str/has_char.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
// -*- 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_ */
|
Loading…
Add table
Add a link
Reference in a new issue