From 29fcfe4010e58d49cad9c1c725fe2bc73942f672 Mon Sep 17 00:00:00 2001 From: John Naylor Date: Fri, 16 Jul 2021 17:45:31 -0400 Subject: [PATCH v17 4/4] Second attempt at addressing performance regressions from chunk approach --- src/common/wchar.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/common/wchar.c b/src/common/wchar.c index 79990fe972..3365521c0a 100644 --- a/src/common/wchar.c +++ b/src/common/wchar.c @@ -1868,20 +1868,21 @@ pg_utf8_verifystr(const unsigned char *s, int len) memcpy(&chunk, s, sizeof(chunk)); - /* fast path for ASCII-subset characters */ - l = check_ascii(chunk); - if (l) - { - s += l; - len -= l; - continue; - } - /* Do a quick check if the first byte is both non-zero and doesn't have the high bit set */ if ((signed char) (*s) > 0) { - s++; - len--; + /* fast path for ASCII-subset characters */ + l = check_ascii(chunk); + if (l) + { + s += l; + len -= l; + } + else + { + s++; + len--; + } continue; } -- 2.31.1