summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/PublicMethods.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-04-15 13:15:12 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-15 13:15:12 -0700
commit018935c9304bebf13fbad20b124d775ccae87fae (patch)
treea8db5b909a5cef43317d924919e7c1be77c505c3 /fpdfsdk/javascript/PublicMethods.cpp
parentc3b26b1479824aa5ce745c220a82de7528bc26a9 (diff)
downloadpdfium-018935c9304bebf13fbad20b124d775ccae87fae.tar.xz
Pass WideStrings without narrowing to c_str in javascript/
Avoid string duplication when the caller already has one. Review URL: https://codereview.chromium.org/1883273003
Diffstat (limited to 'fpdfsdk/javascript/PublicMethods.cpp')
-rw-r--r--fpdfsdk/javascript/PublicMethods.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp
index 9f7b60f70d..a84c0935bc 100644
--- a/fpdfsdk/javascript/PublicMethods.cpp
+++ b/fpdfsdk/javascript/PublicMethods.cpp
@@ -306,7 +306,7 @@ double CJS_PublicMethods::ParseNormalDate(const CFX_WideString& value,
CFX_WideString swTemp;
swTemp.Format(L"%d/%d/%d %d:%d:%d", nMonth, nDay, nYear, nHour, nMin, nSec);
- return JS_DateParse(swTemp.c_str());
+ return JS_DateParse(swTemp);
}
double CJS_PublicMethods::MakeRegularDate(const CFX_WideString& value,
@@ -563,24 +563,21 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString& value,
bBadFormat = true;
double dRet = 0;
-
if (bBadFormat) {
dRet = ParseNormalDate(value, &bBadFormat);
} else {
dRet = JS_MakeDate(JS_MakeDay(nYear, nMonth - 1, nDay),
JS_MakeTime(nHour, nMin, nSec, 0));
-
- if (JS_PortIsNan(dRet)) {
- dRet = JS_DateParse(value.c_str());
- }
+ if (JS_PortIsNan(dRet))
+ dRet = JS_DateParse(value);
}
- if (JS_PortIsNan(dRet)) {
+ if (JS_PortIsNan(dRet))
dRet = ParseNormalDate(value, &bBadFormat);
- }
if (bWrongFormat)
*bWrongFormat = bBadFormat;
+
return dRet;
}
@@ -1204,7 +1201,7 @@ double CJS_PublicMethods::MakeInterDate(const CFX_WideString& strValue) {
double dRet = JS_MakeDate(JS_MakeDay(nYear, nMonth - 1, nDay),
JS_MakeTime(nHour, nMin, nSec, 0));
if (JS_PortIsNan(dRet))
- dRet = JS_DateParse(strValue.c_str());
+ dRet = JS_DateParse(strValue);
return dRet;
}