summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Wellons <wellons@nullprogram.com>2017-10-06 11:31:29 -0400
committerChristopher Wellons <wellons@nullprogram.com>2017-10-06 11:31:29 -0400
commit03f35f2a6aaf0670425dca6bcedbcd5d370c58bf (patch)
tree35787c82831509275288c267c81e8b8b93797710
parent15924e1250595989805c5994383b58224cce0b8b (diff)
Eliminate a shift
-rw-r--r--utf8.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/utf8.h b/utf8.h
index 19eef17..d4444db 100644
--- a/utf8.h
+++ b/utf8.h
@@ -25,7 +25,7 @@ utf8_decode(void *buf, uint32_t *c, int *e) {
0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 4, 0
};
static const int masks[] = {0x00, 0x7f, 0x1f, 0x0f, 0x07};
- static const int thresh[] = {22, 0, 7, 11, 16};
+ static const uint32_t thresh[] = {4194304, 0, 128, 2048, 65536};
static const int shiftc[] = {0, 18, 12, 6, 0};
static const int shifte[] = {0, 6, 4, 2, 0};
@@ -48,7 +48,7 @@ utf8_decode(void *buf, uint32_t *c, int *e) {
*c >>= shiftc[len];
/* Accumulate the various error conditions. */
- *e = (*c < (UINT32_C(1) << thresh[len]) - 1) << 6;
+ *e = (*c < thresh[len]) << 6;
*e |= ((*c >> 11) == 0x1b) << 7; // surrogate half?
*e |= (s[1] & 0xc0) >> 2;
*e |= (s[2] & 0xc0) >> 4;