use value_or() in FormatNumStr()
Just doesn't read right otherwise.
Change-Id: I4175323a3774a44e9b053e9e657d4542f82b023e
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/93150
Auto-Submit: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 15d859f..8986666 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -653,23 +653,21 @@
wsSrcNum.Delete(0, 1);
}
- auto dot_index = wsSrcNum.Find('.');
- dot_index = !dot_index.has_value() ? wsSrcNum.GetLength() : dot_index;
-
- if (dot_index.value() < 1)
+ size_t dot_index = wsSrcNum.Find('.').value_or(wsSrcNum.GetLength());
+ if (dot_index == 0)
return WideString();
- size_t nPos = dot_index.value() % 3;
+ size_t nPos = dot_index % 3;
WideString wsOutput;
- for (size_t i = 0; i < dot_index.value(); i++) {
+ for (size_t i = 0; i < dot_index; i++) {
if (i % 3 == nPos && i != 0)
wsOutput += wsGroupSymbol;
wsOutput += wsSrcNum[i];
}
- if (dot_index.value() < wsSrcNum.GetLength()) {
+ if (dot_index < wsSrcNum.GetLength()) {
wsOutput += pLocale->GetDecimalSymbol();
- wsOutput += wsSrcNum.Last(wsSrcNum.GetLength() - dot_index.value() - 1);
+ wsOutput += wsSrcNum.Last(wsSrcNum.GetLength() - dot_index - 1);
}
if (bNeg)
return pLocale->GetMinusSymbol() + wsOutput;