From 340dbdb625425a4018e51a3bd5d91b54044be4c0 Mon Sep 17 00:00:00 2001
From: John Naylor <john.naylor@2ndquadrant.com>
Date: Fri, 16 Jul 2021 17:41:10 -0400
Subject: [PATCH v17 3/4] First attempt at addressing performance regressions
 from chunk approach

---
 src/common/wchar.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/common/wchar.c b/src/common/wchar.c
index 84cc1c6785..79990fe972 100644
--- a/src/common/wchar.c
+++ b/src/common/wchar.c
@@ -1877,6 +1877,14 @@ pg_utf8_verifystr(const unsigned char *s, int len)
 			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--;
+			continue;
+		}
+
 		/*
 		 * Found non-ASCII or zero above, so verify a single character.
 		 */
-- 
2.31.1

