You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
findStaticChild scanned []*node and dereferenced every child to read its
one-byte label — a pointer chase per static step. Maintain a parallel
scLabels []byte (kept in sync in addStaticChild, newNode, the insert
split, and Remove) and scan that contiguous slice instead, indexing into
staticChildren only on a hit.
benchstat (n=6):
RouterStaticRoutes-14 8.49µ -> 8.01µ -5.67% (p=0.002)
RouterGitHubAPI-14 16.93µ -> 16.45µ -2.86% (p=0.002)
RouterParseAPI / GooglePlusAPI: neutral (param-heavy)
allocations: 0, unchanged
Also fold the is-leaf recomputation (duplicated across 5 sites, with the
Remove copy subtly using len()==0 vs == nil) into a single refreshLeaf()
helper that uses len() so it is correct whether staticChildren is nil or
an emptied-but-non-nil slice left after a removal.
Split out of #3023 so the router and JSON changes can be reviewed
independently (requested by @aldas).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments