From e59e2ed2a293356394990b924a10d4d64ba9d9ca Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Sun, 29 Sep 2024 19:01:51 +0000 Subject: [PATCH] use "len(buf)-1" to access final slice index to eliminate boundary-checks (#160) --- quote.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/quote.go b/quote.go index d1cd6fa..cb12ee3 100644 --- a/quote.go +++ b/quote.go @@ -57,7 +57,7 @@ func Quote(value any) string { buf[i] = b i += 1 } - buf[i] = '\'' + buf[len(buf)-1] = '\'' return unsafe.String(&buf[0], len(buf)) case []byte: @@ -71,7 +71,7 @@ func Quote(value any) string { buf[i+1] = hex[b%16] i += 2 } - buf[i] = '\'' + buf[len(buf)-1] = '\'' return unsafe.String(&buf[0], len(buf)) case ZeroBlob: @@ -107,6 +107,6 @@ func QuoteIdentifier(id string) string { buf[i] = b i += 1 } - buf[i] = '"' + buf[len(buf)-1] = '"' return unsafe.String(&buf[0], len(buf)) }