From d2b9a38a8a24b7d8627e6a8b3fb005ac42f663c5 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 24 May 2026 12:21:02 +0300 Subject: 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. --- internal/rpn/rpn_state.go | 8 -------- 1 file changed, 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() } -- cgit v1.2.3