From 574b574064af5ec0dabf8d49d98d25af6c5d5925 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 30 Mar 2017 12:41:55 -0700 Subject: Fix some nits in the javascript util code. Change-Id: I695ca2c4de589f763557d2c327fdb5906bd1a3cf Reviewed-on: https://pdfium-review.googlesource.com/3411 Reviewed-by: Tom Sepez Commit-Queue: Lei Zhang --- fpdfsdk/javascript/util.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp index 32104b41a6..f88cdc615d 100644 --- a/fpdfsdk/javascript/util.cpp +++ b/fpdfsdk/javascript/util.cpp @@ -113,9 +113,10 @@ bool util::printf(CJS_Runtime* pRuntime, const std::vector& params, CJS_Value& vRet, CFX_WideString& sError) { - int iSize = params.size(); + const size_t iSize = params.size(); if (iSize < 1) return false; + std::wstring c_ConvChar(params[0].ToCFXWideString(pRuntime).c_str()); std::vector c_strConvers; int iOffset = 0; @@ -134,19 +135,19 @@ bool util::printf(CJS_Runtime* pRuntime, std::wstring c_strResult; std::wstring c_strFormat; - for (int iIndex = 0; iIndex < (int)c_strConvers.size(); iIndex++) { + for (size_t iIndex = 0; iIndex < c_strConvers.size(); ++iIndex) { c_strFormat = c_strConvers[iIndex]; if (iIndex == 0) { c_strResult = c_strFormat; continue; } - CFX_WideString strSegment; if (iIndex >= iSize) { c_strResult += c_strFormat; continue; } + CFX_WideString strSegment; switch (ParseDataType(&c_strFormat)) { case UTIL_INT: strSegment.Format(c_strFormat.c_str(), params[iIndex].ToInt(pRuntime)); @@ -175,12 +176,12 @@ bool util::printd(CJS_Runtime* pRuntime, const std::vector& params, CJS_Value& vRet, CFX_WideString& sError) { - int iSize = params.size(); + const size_t iSize = params.size(); if (iSize < 2) return false; - CJS_Value p1 = params[0]; - CJS_Value p2 = params[1]; + const CJS_Value& p1 = params[0]; + const CJS_Value& p2 = params[1]; CJS_Date jsDate; if (!p2.ConvertToDate(pRuntime, jsDate)) { sError = JSGetStringFromID(IDS_STRING_JSPRINT1); @@ -421,8 +422,7 @@ bool util::scand(CJS_Runtime* pRuntime, const std::vector& params, CJS_Value& vRet, CFX_WideString& sError) { - int iSize = params.size(); - if (iSize < 2) + if (params.size() < 2) return false; CFX_WideString sFormat = params[0].ToCFXWideString(pRuntime); -- cgit v1.2.3