add compiler hints to reduce number of slice bounds checks (#158)

* add compiler hints to reduce number of slice bounds checks

* panic on assert instead of returning error for code coverage
This commit is contained in:
kim
2024-09-28 00:26:46 +00:00
committed by GitHub
parent b7055ef04b
commit 32931032d3
2 changed files with 20 additions and 0 deletions

View File

@@ -639,6 +639,14 @@ func (s *Stmt) Columns(dest []any) error {
}
types := util.View(s.c.mod, typePtr, count)
// hint to the compiler that
// it can omit bounds check
// accessing types[i] below.
if len(types) != len(dest) {
panic(util.AssertErr())
}
for i := range dest {
switch types[i] {
case byte(INTEGER):