summaryrefslogtreecommitdiff
path: root/internal/rpn/rpn_parse.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-22 12:33:12 +0300
committerPaul Buetow <paul@buetow.org>2026-05-22 12:33:12 +0300
commit9a68d3658e9d4f71121f90a1e0489898fea849f5 (patch)
treedfd9a946c6118a0831e8af4d3bcd2f7a7f748e68 /internal/rpn/rpn_parse.go
parentcb1e4376afe9f887b9e3b3b2a9ddef116bedb0cc (diff)
rpn: eliminate duplicated prefixMode state between RPN and Operations
Remove the prefixMode field from the RPN struct; it was duplicated from Operations where it is actually used. Add GetPrefixMode to the Operator interface so RPN can delegate both GetPrefixMode and SetPrefixMode to the Operations instance behind the interface. In rpn_parse.go evaluate(), drop the direct r.prefixMode = IEC/SI writes and the now-unnecessary lock ordering comment; only r.ops.SetPrefixMode() remains.
Diffstat (limited to 'internal/rpn/rpn_parse.go')
-rw-r--r--internal/rpn/rpn_parse.go5
1 files changed, 0 insertions, 5 deletions
diff --git a/internal/rpn/rpn_parse.go b/internal/rpn/rpn_parse.go
index 7abd41c..ab64ec7 100644
--- a/internal/rpn/rpn_parse.go
+++ b/internal/rpn/rpn_parse.go
@@ -367,17 +367,12 @@ func (r *RPN) evaluate(input string, tokens []string) (string, error) {
return result, nil
case "binary":
if i+2 < len(tokens) && tokens[i+2] == "set" {
- // Lock order: r.mu → o.mu (same as RPN.SetPrefixMode)
- // No deadlock risk: both paths acquire in the same direction.
- // r.mu is held by evaluate(); o.mu is a separate mutex on Operations.
- r.prefixMode = IEC
r.ops.SetPrefixMode(IEC)
return "prefix mode: IEC", nil
}
return "", fmt.Errorf("rpn: metric binary: use 'metric binary set'")
case "decimal":
if i+2 < len(tokens) && tokens[i+2] == "set" {
- r.prefixMode = SI
r.ops.SetPrefixMode(SI)
return "prefix mode: SI", nil
}