diff options
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/rpn/constants.go | 32 | ||||
| -rw-r--r-- | internal/rpn/variables.go | 4 |
2 files changed, 4 insertions, 32 deletions
diff --git a/internal/rpn/constants.go b/internal/rpn/constants.go index 4c629bd..320ff07 100644 --- a/internal/rpn/constants.go +++ b/internal/rpn/constants.go @@ -147,20 +147,8 @@ func (c *Constants) ClearConstants() { c.mu.Lock() defer c.mu.Unlock() - // Remove only user-defined constants (not built-in ones) - builtIns := map[string]bool{ - "pi": true, "π": true, - "e": true, "euler": true, - "phi": true, "φ": true, - "sqrt2": true, "√2": true, - "inf": true, "infinity": true, - "nan": true, - } - for k := range c.constants { - if !builtIns[k] { - delete(c.constants, k) - } - } + clear(c.constants) + c.loadBuiltInConstants() } // ReloadBuiltInConstants restores all built-in constants. @@ -170,21 +158,7 @@ func (c *Constants) ReloadBuiltInConstants() { c.mu.Lock() defer c.mu.Unlock() - // First remove only user-defined constants - builtIns := map[string]bool{ - "pi": true, "π": true, - "e": true, "euler": true, - "phi": true, "φ": true, - "sqrt2": true, "√2": true, - "inf": true, "infinity": true, - "nan": true, - } - for k := range c.constants { - if !builtIns[k] { - delete(c.constants, k) - } - } - // Then reload built-in constants + clear(c.constants) c.loadBuiltInConstants() } 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. |
