Skip to content

Eliminate unnecessary bounds checks in hot paths#1381

Merged
mattn merged 1 commit intomasterfrom
eliminate-bounds-checks
Mar 30, 2026
Merged

Eliminate unnecessary bounds checks in hot paths#1381
mattn merged 1 commit intomasterfrom
eliminate-bounds-checks

Conversation

@mattn
Copy link
Copy Markdown
Owner

@mattn mattn commented Mar 30, 2026

Reduce bounds checks in performance-sensitive code paths by using range loops, avoiding redundant slice expressions, and adding compiler hints. Benchmarks show ~2-3% improvement in Rows/StmtRows/Params/Stmt benchmarks.

- Replace len(args[start:start+na]) > 0 with na > 0 to avoid slice bounds check
- Use range loops instead of manual index loops for cols/decltype slices
- Use range variable v.Ordinal instead of re-indexing args[i].Ordinal
- Add bounds hint for decltype access in nextSyncLocked loop
@mattn mattn merged commit edadafa into master Mar 30, 2026
20 checks passed
@mattn mattn deleted the eliminate-bounds-checks branch March 30, 2026 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant