summaryrefslogtreecommitdiff
path: root/fpdfsdk/src
diff options
context:
space:
mode:
authorBruce Dawson <brucedawson@google.com>2015-01-02 12:05:17 -0800
committerBruce Dawson <brucedawson@google.com>2015-01-02 12:05:17 -0800
commit87e9598a159d17a3b45821635b7ad43a18dd6f11 (patch)
tree96cca35ad9e6eca45122a214d39d5dd11ab51819 /fpdfsdk/src
parent9c5208319a89ce3ebdf261235bb4aaaa8e540470 (diff)
downloadpdfium-87e9598a159d17a3b45821635b7ad43a18dd6f11.tar.xz
XFA: merge patch from CL 788143009, remove g_NaN var and constructor
Doing the type conversion on demand is just as efficient as doing it at startup time, and makes for more efficient startup. Also mark g_nan as const, to reduce .data section size and enforce desired semantics. BUG=441899 TBR=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/788143009 Review URL: https://codereview.chromium.org/832933002
Diffstat (limited to 'fpdfsdk/src')
-rw-r--r--fpdfsdk/src/jsapi/fxjs_v8.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/fpdfsdk/src/jsapi/fxjs_v8.cpp b/fpdfsdk/src/jsapi/fxjs_v8.cpp
index d5d0aa1566..46a6cba360 100644
--- a/fpdfsdk/src/jsapi/fxjs_v8.cpp
+++ b/fpdfsdk/src/jsapi/fxjs_v8.cpp
@@ -21,8 +21,11 @@
#define VALUE_NAME_NULL L"null"
#define VALUE_NAME_UNDEFINED L"undefined"
-static FX_DWORD g_nan[2] = {0,0x7FF80000 };
-double g_NaN = (*(double *)g_nan);
+const static FX_DWORD g_nan[2] = {0,0x7FF80000 };
+static double GetNan()
+{
+ return *(double*)g_nan;
+}
class CJS_PrivateData: public CFX_Object
@@ -995,7 +998,7 @@ double JS_DateParse(const wchar_t* string)
double JS_MakeDay(int nYear, int nMonth, int nDate)
{
if (!_isfinite(nYear) || !_isfinite(nMonth) ||!_isfinite(nDate))
- return g_NaN;
+ return GetNan();
double y = _toInteger(nYear);
double m = _toInteger(nMonth);
double dt = _toInteger(nDate);
@@ -1005,14 +1008,14 @@ double JS_MakeDay(int nYear, int nMonth, int nDate)
double t = _TimeFromYearMonth((int)ym,(int)mn);
if (_YearFromTime(t) != ym || _MonthFromTime(t) != mn ||_DateFromTime(t) != 1)
- return g_NaN;
+ return GetNan();
return _Day(t)+dt-1;
}
double JS_MakeTime(int nHour, int nMin, int nSec, int nMs)
{
if (!_isfinite(nHour) ||!_isfinite(nMin) ||!_isfinite(nSec) ||!_isfinite(nMs))
- return g_NaN;
+ return GetNan();
double h = _toInteger(nHour);
double m = _toInteger(nMin);
@@ -1025,7 +1028,7 @@ double JS_MakeTime(int nHour, int nMin, int nSec, int nMs)
double JS_MakeDate(double day, double time)
{
if (!_isfinite(day) ||!_isfinite(time))
- return g_NaN;
+ return GetNan();
return day * 86400000 + time;
}