diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-24 12:21:02 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-24 12:21:02 +0300 |
| commit | d2b9a38a8a24b7d8627e6a8b3fb005ac42f663c5 (patch) | |
| tree | ae72d721d3a0a6615e0c3f10a1af662d3bc233b8 | |
| parent | cb5824fc780c36db51361ab17e2849c1e1b30ccf (diff) | |
rpn: remove redundant mutex locking in RPN mode/prefix wrappers
RPN.GetMode/SetMode/GetPrefixMode/SetPrefixMode acquired r.mu
before delegating to Operations methods that already acquire
o.mu. Since Operations guards mode and prefixMode with its own
RWMutex, the RPN-level locks were redundant double-locking
on separate mutexes for the same data.
Removed the r.mu locking from these four methods. Thread safety
is preserved by Operations' internal mutex.
| -rw-r--r-- | internal/rpn/rpn_state.go | 8 |
1 files changed, 0 insertions, 8 deletions
diff --git a/internal/rpn/rpn_state.go b/internal/rpn/rpn_state.go index 474f164..2721cd1 100644 --- a/internal/rpn/rpn_state.go +++ b/internal/rpn/rpn_state.go @@ -48,16 +48,12 @@ func (r *RPN) GetConstants() ConstantsProvider { // GetMode returns the current calculation mode. // This method is thread-safe for reads. func (r *RPN) GetMode() CalculationMode { - r.mu.RLock() - defer r.mu.RUnlock() return r.ops.GetMode() } // SetMode sets the calculation mode. // This method is thread-safe for writes. func (r *RPN) SetMode(mode CalculationMode) { - r.mu.Lock() - defer r.mu.Unlock() r.ops.SetMode(mode) } @@ -96,8 +92,6 @@ func (r *RPN) Stack() []StackValue { // Delegates to the Operations instance. // This method is thread-safe for writes. func (r *RPN) SetPrefixMode(mode PrefixMode) { - r.mu.Lock() - defer r.mu.Unlock() r.ops.SetPrefixMode(mode) } @@ -105,8 +99,6 @@ func (r *RPN) SetPrefixMode(mode PrefixMode) { // Delegates to the Operations instance. // This method is thread-safe for reads. func (r *RPN) GetPrefixMode() PrefixMode { - r.mu.RLock() - defer r.mu.RUnlock() return r.ops.GetPrefixMode() } |
