use "len(buf)-1" to access final slice index to eliminate boundary-checks (#160)

This commit is contained in:
kim
2024-09-29 19:01:51 +00:00
committed by GitHub
parent 505c6640c2
commit e59e2ed2a2

View File

@@ -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))
}