summaryrefslogtreecommitdiff
path: root/internal/rpn/variables.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-23 23:28:17 +0300
committerPaul Buetow <paul@buetow.org>2026-05-23 23:28:17 +0300
commit26d4eb8d02f669a7526ff981fc184f902798b118 (patch)
treec91a7e0e36783ed70d19de2e3e0a3ba7bc209292 /internal/rpn/variables.go
parentc1c9804db06e01efceef032347768e218d50f497 (diff)
rpn: use clear() builtin instead of loop+delete
Replace the manual for-range-delete pattern with Go 1.21+ clear() builtin in Variables.ClearVariables() and Constants.ClearConstants(). Also simplified ReloadBuiltInConstants() which used the same pattern. clear() is cleaner, more idiomatic, and slightly faster for clearing entire maps.
Diffstat (limited to 'internal/rpn/variables.go')
-rw-r--r--internal/rpn/variables.go4
1 files changed, 1 insertions, 3 deletions
diff --git a/internal/rpn/variables.go b/internal/rpn/variables.go
index efc2a8d..7e6b209 100644
--- a/internal/rpn/variables.go
+++ b/internal/rpn/variables.go
@@ -159,9 +159,7 @@ func (v *Variables) ClearVariables() {
v.mu.Lock()
defer v.mu.Unlock()
- for k := range v.variables {
- delete(v.variables, k)
- }
+ clear(v.variables)
}
// formatVariablesUnsafe returns a list of variable info without acquiring a lock.