Fix some nits in CFXJSE_FormCalcContext.
- Use -- and ++ operators.
- Declare some variables when first used.
Change-Id: I78fd92fe2b2b7351a4c648a5a7df941fdb3d6a37
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/53616
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/xfa/cfxjse_formcalc_context.cpp b/fxjs/xfa/cfxjse_formcalc_context.cpp
index 6782fb6..387879c 100644
--- a/fxjs/xfa/cfxjse_formcalc_context.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context.cpp
@@ -817,7 +817,7 @@
}
i = 0;
while (iDay - i > 0) {
- dDays += 1;
+ ++dDays;
++i;
}
return (int32_t)dDays;
@@ -1249,7 +1249,7 @@
iIndex += 2;
} else if (iFirstCount == 1) {
strBuf << pCapUnits[pData[iIndex] - '0'];
- iIndex += 1;
+ ++iIndex;
}
if (iLength > 3 && iFirstCount > 0) {
strBuf << pComm[iComm];
@@ -4246,7 +4246,7 @@
bsInsert = ValueToUTF8String(insertValue.get());
}
- iStart -= 1;
+ --iStart;
std::ostringstream szResult;
int32_t i = 0;
while (i < iStart) {
@@ -4282,8 +4282,6 @@
return;
}
- int32_t iStart = 0;
- int32_t iCount = 0;
ByteString bsSource = ValueToUTF8String(stringValue.get());
int32_t iLength = bsSource.GetLength();
if (iLength == 0) {
@@ -4291,12 +4289,12 @@
return;
}
- iStart = pdfium::clamp(
+ int32_t iStart = pdfium::clamp(
iLength, 1, static_cast<int32_t>(ValueToFloat(pThis, startValue.get())));
- iCount =
+ int32_t iCount =
std::max(0, static_cast<int32_t>(ValueToFloat(pThis, endValue.get())));
- iStart -= 1;
+ --iStart;
args.GetReturnValue()->SetString(bsSource.Mid(iStart, iCount).AsStringView());
}
@@ -5168,7 +5166,7 @@
int32_t length = lengthValue->ToInteger();
iLength = iLength + ((length > 2) ? (length - 2) : 0);
}
- iLength += 1;
+ ++iLength;
}
std::vector<std::unique_ptr<CFXJSE_Value>> returnValues;
@@ -5324,7 +5322,7 @@
int32_t iLength = lengthValue->ToInteger();
iCount += ((iLength > 2) ? (iLength - 2) : 0);
} else {
- iCount += 1;
+ ++iCount;
}
}