WeKnora/internal/sandbox
adawang 8f4b3333f2 perf(sandbox): compile command-substitution regexps once
hasCommandSubstitution recompiled its three regexps with regexp.MustCompile
on every call, and ValidateArgs calls it once per argument — so validating
an N-arg command compiled 3N patterns. Hoist them to a package-level slice
compiled once at init.

Behavior is unchanged (same patterns); covered by the existing
TestScriptValidator_ValidateArgs / ValidateAll tests.

Benchmark, ValidateArgs with 8 args (-benchmem):
  before: 16374 ns/op, 40142 B/op, 505 allocs/op
  after:   2092 ns/op,    32 B/op,   1 allocs/op

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 19:51:32 +08:00
..
docker.go feat: optimize security and deployment of agent skills 2026-02-04 20:08:49 +08:00
local.go 增加sandbox对windows编译支持,现在默认是linux的实现,windows直接编译报错 2026-05-25 16:57:56 +08:00
local_unix.go 增加sandbox对windows编译支持,现在默认是linux的实现,windows直接编译报错 2026-05-25 16:57:56 +08:00
local_windows.go 增加sandbox对windows编译支持,现在默认是linux的实现,windows直接编译报错 2026-05-25 16:57:56 +08:00
manager.go feat: optimize security and deployment of agent skills 2026-02-04 20:08:49 +08:00
sandbox.go feat: optimize security and deployment of agent skills 2026-02-04 20:08:49 +08:00
sandbox_test.go feat: support agent skills 2026-02-04 20:08:49 +08:00
validator.go perf(sandbox): compile command-substitution regexps once 2026-06-16 19:51:32 +08:00
validator_test.go perf(sandbox): compile command-substitution regexps once 2026-06-16 19:51:32 +08:00