mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 22:02:27 +00:00
Reduce number of disk seeks in redbean
This commit is contained in:
parent
daa32d27d4
commit
01e6b3ad8d
8 changed files with 212 additions and 173 deletions
|
@ -33,13 +33,14 @@
|
|||
ssize_t HasControlCodes(const char *p, size_t n, int f) {
|
||||
char t[256];
|
||||
wint_t x, a, b;
|
||||
size_t i, j, m;
|
||||
size_t i, j, m, g;
|
||||
memset(t, 0, sizeof(t));
|
||||
if (f & kControlC0) memset(t + 0x00, 1, 0x20 - 0x00), t[0x7F] = 1;
|
||||
if (f & kControlC1) memset(t + 0x80, 1, 0xA0 - 0x80);
|
||||
t['\t'] = t['\r'] = t['\n'] = t['\v'] = !!(f & kControlWs);
|
||||
if (n == -1) n = p ? strlen(p) : 0;
|
||||
for (i = 0; i < n;) {
|
||||
g = i;
|
||||
x = p[i++] & 0xff;
|
||||
if (UNLIKELY(x >= 0300)) {
|
||||
a = ThomPikeByte(x);
|
||||
|
@ -58,7 +59,7 @@ ssize_t HasControlCodes(const char *p, size_t n, int f) {
|
|||
}
|
||||
}
|
||||
if (x < 256 && t[x]) {
|
||||
return i - 1;
|
||||
return g;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue