Skip to content

Commit a088bc3

Browse files
committed
test(alloc): gate FilterArgs at its pre-sized floor (1 alloc)
Co-Authored-By: Virgil <virgil@lethean.io>
1 parent e2ba33a commit a088bc3

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

alloc_gate_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,15 @@ func TestAllocs_LSPComputeDiagnostics(t *T) {
117117
}))
118118
AssertLessOrEqual(t, avg, 70, "LSPComputeDiagnostics")
119119
}
120+
121+
var gateStrSlice []string
122+
123+
// TestAllocs_FilterArgs locks the pre-size win (1f59e31): was an unpresized
124+
// 'var clean []string' + append (geometric regrow), now the single presized
125+
// result allocation. (Typed sink — assigning to `any` would box and add a
126+
// spurious alloc.)
127+
func TestAllocs_FilterArgs(t *T) {
128+
args := []string{"deploy", "--target", "homelab", "-v"}
129+
fa := int(testing.AllocsPerRun(1000, func() { gateStrSlice = FilterArgs(args) }))
130+
AssertLessOrEqual(t, fa, 1, "FilterArgs")
131+
}

0 commit comments

Comments
 (0)