summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/jsapi
diff options
context:
space:
mode:
authorBruce Dawson <brucedawson@google.com>2015-01-02 11:59:15 -0800
committerBruce Dawson <brucedawson@google.com>2015-01-02 11:59:15 -0800
commitd66051b5edfee0279b504b49f7d167f03c17c6dd (patch)
tree2147e01fab8a17030091ebcb28dd30207bd1cbee /fpdfsdk/src/jsapi
parent659a56bcbeb12b22708fe979d12b318080d828ba (diff)
downloadpdfium-d66051b5edfee0279b504b49f7d167f03c17c6dd.tar.xz
Remove g_NaN global variable and its 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 R=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/788143009
Diffstat (limited to 'fpdfsdk/src/jsapi')
-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 7d919a74f8..a3f7b6ddd3 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
@@ -992,7 +995,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);
@@ -1002,14 +1005,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);
@@ -1022,7 +1025,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;
}