diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-24 00:22:02 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-24 00:22:02 +0300 |
| commit | d334ad95fb3413d15549960a0c3c1c4739ae5055 (patch) | |
| tree | 4a51a89c9546051b7f60428eb419d29e5df4f857 | |
| parent | a3acc6f607b4422b83e023c030892ff39c0cb0aa (diff) | |
fix(rpn): correct misleading comments in metric_parse.go
- Fix comment claiming '42abc' is caught by the pre-check: only
single-char suffixes like '10x' are filtered early; '42abc' (3-char
suffix) passes through to the registry lookup.
- Fix comment 'Must have consumed at least one digit character': the
check only verifies at least one character was consumed by the scanner;
digit validation is actually deferred to ParseFloat.
| -rw-r--r-- | internal/rpn/metric_parse.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/internal/rpn/metric_parse.go b/internal/rpn/metric_parse.go index be6df93..227fcca 100644 --- a/internal/rpn/metric_parse.go +++ b/internal/rpn/metric_parse.go @@ -44,7 +44,8 @@ func parseNumberWithMetric(token string, reg *MetricRegistry) (float64, *Metric, } } - // Must have consumed at least one digit character + // Must have consumed at least one character in the numeric portion; + // actual digit validation is deferred to ParseFloat. if i == start { return 0, nil, false } @@ -58,7 +59,7 @@ func parseNumberWithMetric(token string, reg *MetricRegistry) (float64, *Metric, metricName := token[i:] // Early pre-check: skip unlikely metric suffixes to avoid - // unnecessary registry lookups for tokens like "10x", "42abc". + // unnecessary registry lookups for tokens like "10x". // All built-in metric names are >= 2 chars, except for three // single-char metrics: s (seconds), m (meters), g (grams). // Require suffix length >= 2, or be one of those known singles. |
