v18-0006-Do-8-byte-check-only-if-1-byte-check-succeeds.patch
application/octet-stream
Filename: v18-0006-Do-8-byte-check-only-if-1-byte-check-succeeds.patch
Type: application/octet-stream
Part: 5
Message:
Re: speed up verifying UTF-8
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v18-0006
Subject: Do 8-byte check only if 1-byte check succeeds
| File | + | − |
|---|---|---|
| src/common/wchar.c | 12 | 11 |
From d682593567d6b47ed12455caf6a50e9f0b6416fc Mon Sep 17 00:00:00 2001
From: John Naylor <john.naylor@2ndquadrant.com>
Date: Sun, 18 Jul 2021 19:31:44 -0400
Subject: [PATCH v18 6/6] Do 8-byte check only if 1-byte check succeeds
---
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 465efd2e0d..a388ff4cba 100644
--- a/src/common/wchar.c
+++ b/src/common/wchar.c
@@ -1983,20 +1983,21 @@ pg_utf8_verifystr(const unsigned char *s, int len)
{
int l;
- /* fast path for ASCII-subset characters */
- l = check_ascii(s, 8);
- if (l)
- {
- s += l;
- len -= l;
- continue;
- }
-
/* 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(s, 8);
+ if (l)
+ {
+ s += l;
+ len -= l;
+ }
+ else
+ {
+ s++;
+ len--;
+ }
continue;
}
--
2.31.1