diff options
author | tsepez <tsepez@chromium.org> | 2016-04-15 13:15:12 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-15 13:15:12 -0700 |
commit | 018935c9304bebf13fbad20b124d775ccae87fae (patch) | |
tree | a8db5b909a5cef43317d924919e7c1be77c505c3 /fpdfsdk/javascript/PublicMethods.cpp | |
parent | c3b26b1479824aa5ce745c220a82de7528bc26a9 (diff) | |
download | pdfium-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.cpp | 15 |
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; } |