diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-04-17 15:38:19 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-04-18 17:17:36 +0000 |
commit | 3c3e271ea9fd19dd535a74b5546b27e3e82dcb81 (patch) | |
tree | e73049f2d18718da9ff8d42b46f31009c5e6e887 /fpdfsdk/javascript/PublicMethods.cpp | |
parent | 94c5e25840046b7bf976d2d568e19ad63b656ade (diff) | |
download | pdfium-3c3e271ea9fd19dd535a74b5546b27e3e82dcb81.tar.xz |
Use Byte/WideString iterators
Change-Id: I85c8423c177fd7ecd5da90ef89419efc0f9cf44b
Reviewed-on: https://pdfium-review.googlesource.com/4262
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript/PublicMethods.cpp')
-rw-r--r-- | fpdfsdk/javascript/PublicMethods.cpp | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp index f479527ef6..b5d4f7ba55 100644 --- a/fpdfsdk/javascript/PublicMethods.cpp +++ b/fpdfsdk/javascript/PublicMethods.cpp @@ -1141,8 +1141,7 @@ bool CJS_PublicMethods::AFDate_FormatEx(CJS_Runtime* pRuntime, double CJS_PublicMethods::MakeInterDate(const CFX_WideString& strValue) { std::vector<CFX_WideString> wsArray; CFX_WideString sTemp = L""; - for (int i = 0; i < strValue.GetLength(); ++i) { - wchar_t c = strValue.GetAt(i); + for (const auto& c : strValue) { if (c == L' ' || c == L':') { wsArray.push_back(sTemp); sTemp = L""; @@ -1775,22 +1774,17 @@ bool CJS_PublicMethods::AFExtractNums(CJS_Runtime* pRuntime, CFX_WideString sPart; CJS_Array nums; int nIndex = 0; - for (int i = 0, sz = str.GetLength(); i < sz; i++) { - wchar_t wc = str.GetAt(i); + for (const auto& wc : str) { if (FXSYS_iswdigit(wc)) { sPart += wc; - } else { - if (sPart.GetLength() > 0) { - nums.SetElement(pRuntime, nIndex, CJS_Value(pRuntime, sPart.c_str())); - sPart = L""; - nIndex++; - } + } else if (sPart.GetLength() > 0) { + nums.SetElement(pRuntime, nIndex, CJS_Value(pRuntime, sPart.c_str())); + sPart = L""; + nIndex++; } } - - if (sPart.GetLength() > 0) { + if (sPart.GetLength() > 0) nums.SetElement(pRuntime, nIndex, CJS_Value(pRuntime, sPart.c_str())); - } if (nums.GetLength(pRuntime) > 0) vRet = CJS_Value(pRuntime, nums); |