Bug 793076 (part 7) - Rename CacheLocalTimes() and change its return type from bool to void. r=jwalden.
authorNicholas Nethercote <nnethercote@mozilla.com>
Sun, 07 Oct 2012 18:01:54 -0700
changeset 109600 99229a1bf7eab4a9da02a4b2292d8cad17cfaea0
parent 109599 0a0f23cf7a7a7dbb8b5f8e37d1abc813a69f2f57
child 109601 396196c97862cea92e9ff5ad53a70d178fedadc0
push id23636
push usergsharp@mozilla.com
push dateMon, 08 Oct 2012 08:08:19 +0000
treeherdermozilla-central@24cf40690042 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwalden
bugs793076
milestone18.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 793076 (part 7) - Rename CacheLocalTimes() and change its return type from bool to void. r=jwalden.
js/src/jsdate.cpp
--- a/js/src/jsdate.cpp
+++ b/js/src/jsdate.cpp
@@ -1280,40 +1280,40 @@ SetUTCTime(RawObject obj, double t, Valu
         vp->setDouble(t);
 }
 
 /*
  * Cache the local time, year, month, and so forth of the object.
  * If UTC time is not finite (e.g., NaN), the local time
  * slots will be set to the UTC time without conversion.
  */
-static bool
-CacheLocalTime(DSTOffsetCache *dstOffsetCache, RawObject obj)
+static void
+FillLocalTimeSlots(DSTOffsetCache *dstOffsetCache, RawObject obj)
 {
     JS_ASSERT(obj->isDate());
 
     /* Check if the cache is already populated. */
     if (!obj->getSlot(JSObject::JSSLOT_DATE_LOCAL_TIME).isUndefined() &&
         obj->getSlot(JSObject::JSSLOT_DATE_TZA).toDouble() == LocalTZA)
     {
-        return true;
+        return;
     }
 
     /* Remember timezone used to generate the local cache. */
     obj->setSlot(JSObject::JSSLOT_DATE_TZA, DoubleValue(LocalTZA));
 
     double utcTime = obj->getDateUTCTime().toNumber();
 
     if (!MOZ_DOUBLE_IS_FINITE(utcTime)) {
         for (size_t ind = JSObject::JSSLOT_DATE_COMPONENTS_START;
              ind < JSObject::DATE_CLASS_RESERVED_SLOTS;
              ind++) {
             obj->setSlot(ind, DoubleValue(utcTime));
         }
-        return true;
+        return;
     }
 
     double localTime = LocalTime(utcTime, dstOffsetCache);
 
     obj->setSlot(JSObject::JSSLOT_DATE_LOCAL_TIME, DoubleValue(localTime));
 
     int year = (int) floor(localTime /(msPerDay * 365.2425)) + 1970;
     double yearStartTime = TimeFromYear(year);
@@ -1413,26 +1413,25 @@ CacheLocalTime(DSTOffsetCache *dstOffset
     int seconds = yearSeconds % 60;
     obj->setSlot(JSObject::JSSLOT_DATE_LOCAL_SECONDS, Int32Value(seconds));
 
     int minutes = (yearSeconds / 60) % 60;
     obj->setSlot(JSObject::JSSLOT_DATE_LOCAL_MINUTES, Int32Value(minutes));
 
     int hours = (yearSeconds / (60 * 60)) % 24;
     obj->setSlot(JSObject::JSSLOT_DATE_LOCAL_HOURS, Int32Value(hours));
-
-    return true;
 }
 
 inline bool
 GetCachedLocalTime(DSTOffsetCache *dstOffsetCache, RawObject obj, double *time)
 {
-    if (!obj || !CacheLocalTime(dstOffsetCache, obj))
+    if (!obj)
         return false;
 
+    FillLocalTimeSlots(dstOffsetCache, obj);
     *time = obj->getSlot(JSObject::JSSLOT_DATE_LOCAL_TIME).toDouble();
     return true;
 }
 
 JS_ALWAYS_INLINE bool
 IsDate(const Value &v)
 {
     return v.isObject() && v.toObject().hasClass(&DateClass);
@@ -1457,18 +1456,17 @@ date_getTime(JSContext *cx, unsigned arg
 }
 
 JS_ALWAYS_INLINE bool
 date_getYear_impl(JSContext *cx, CallArgs args)
 {
     JS_ASSERT(IsDate(args.thisv()));
 
     RootedObject thisObj(cx, &args.thisv().toObject());
-    if (!CacheLocalTime(&cx->dstOffsetCache, thisObj))
-        return false;
+    FillLocalTimeSlots(&cx->dstOffsetCache, thisObj);
 
     Value yearVal = thisObj->getSlot(JSObject::JSSLOT_DATE_LOCAL_YEAR);
     if (yearVal.isInt32()) {
         /* Follow ECMA-262 to the letter, contrary to IE JScript. */
         int year = yearVal.toInt32() - 1900;
         args.rval().setInt32(year);
     } else {
         args.rval().set(yearVal);
@@ -1485,18 +1483,17 @@ date_getYear(JSContext *cx, unsigned arg
 }
 
 JS_ALWAYS_INLINE bool
 date_getFullYear_impl(JSContext *cx, CallArgs args)
 {
     JS_ASSERT(IsDate(args.thisv()));
 
     RootedObject thisObj(cx, &args.thisv().toObject());
-    if (!CacheLocalTime(&cx->dstOffsetCache, thisObj))
-        return false;
+    FillLocalTimeSlots(&cx->dstOffsetCache, thisObj);
 
     args.rval().set(thisObj->getSlot(JSObject::JSSLOT_DATE_LOCAL_YEAR));
     return true;
 }
 
 static JSBool
 date_getFullYear(JSContext *cx, unsigned argc, Value *vp)
 {
@@ -1525,18 +1522,17 @@ date_getUTCFullYear(JSContext *cx, unsig
 }
 
 JS_ALWAYS_INLINE bool
 date_getMonth_impl(JSContext *cx, CallArgs args)
 {
     JS_ASSERT(IsDate(args.thisv()));
 
     RootedObject thisObj(cx, &args.thisv().toObject());
-    if (!CacheLocalTime(&cx->dstOffsetCache, thisObj))
-        return false;
+    FillLocalTimeSlots(&cx->dstOffsetCache, thisObj);
 
     args.rval().set(thisObj->getSlot(JSObject::JSSLOT_DATE_LOCAL_MONTH));
     return true;
 }
 
 static JSBool
 date_getMonth(JSContext *cx, unsigned argc, Value *vp)
 {
@@ -1562,18 +1558,17 @@ date_getUTCMonth(JSContext *cx, unsigned
 }
 
 JS_ALWAYS_INLINE bool
 date_getDate_impl(JSContext *cx, CallArgs args)
 {
     JS_ASSERT(IsDate(args.thisv()));
 
     RootedObject thisObj(cx, &args.thisv().toObject());
-    if (!CacheLocalTime(&cx->dstOffsetCache, thisObj))
-        return false;
+    FillLocalTimeSlots(&cx->dstOffsetCache, thisObj);
 
     args.rval().set(thisObj->getSlot(JSObject::JSSLOT_DATE_LOCAL_DATE));
     return true;
 }
 
 static JSBool
 date_getDate(JSContext *cx, unsigned argc, Value *vp)
 {
@@ -1602,18 +1597,17 @@ date_getUTCDate(JSContext *cx, unsigned 
 }
 
 JS_ALWAYS_INLINE bool
 date_getDay_impl(JSContext *cx, CallArgs args)
 {
     JS_ASSERT(IsDate(args.thisv()));
 
     RootedObject thisObj(cx, &args.thisv().toObject());
-    if (!CacheLocalTime(&cx->dstOffsetCache, thisObj))
-        return false;
+    FillLocalTimeSlots(&cx->dstOffsetCache, thisObj);
 
     args.rval().set(thisObj->getSlot(JSObject::JSSLOT_DATE_LOCAL_DAY));
     return true;
 }
 
 static JSBool
 date_getDay(JSContext *cx, unsigned argc, Value *vp)
 {
@@ -1642,18 +1636,17 @@ date_getUTCDay(JSContext *cx, unsigned a
 }
 
 JS_ALWAYS_INLINE bool
 date_getHours_impl(JSContext *cx, CallArgs args)
 {
     JS_ASSERT(IsDate(args.thisv()));
 
     RootedObject thisObj(cx, &args.thisv().toObject());
-    if (!CacheLocalTime(&cx->dstOffsetCache, thisObj))
-        return false;
+    FillLocalTimeSlots(&cx->dstOffsetCache, thisObj);
 
     args.rval().set(thisObj->getSlot(JSObject::JSSLOT_DATE_LOCAL_HOURS));
     return true;
 }
 
 static JSBool
 date_getHours(JSContext *cx, unsigned argc, Value *vp)
 {
@@ -1682,18 +1675,17 @@ date_getUTCHours(JSContext *cx, unsigned
 }
 
 JS_ALWAYS_INLINE bool
 date_getMinutes_impl(JSContext *cx, CallArgs args)
 {
     JS_ASSERT(IsDate(args.thisv()));
 
     RootedObject thisObj(cx, &args.thisv().toObject());
-    if (!CacheLocalTime(&cx->dstOffsetCache, thisObj))
-        return false;
+    FillLocalTimeSlots(&cx->dstOffsetCache, thisObj);
 
     args.rval().set(thisObj->getSlot(JSObject::JSSLOT_DATE_LOCAL_MINUTES));
     return true;
 }
 
 static JSBool
 date_getMinutes(JSContext *cx, unsigned argc, Value *vp)
 {
@@ -1724,18 +1716,17 @@ date_getUTCMinutes(JSContext *cx, unsign
 /* Date.getSeconds is mapped to getUTCSeconds */
 
 JS_ALWAYS_INLINE bool
 date_getUTCSeconds_impl(JSContext *cx, CallArgs args)
 {
     JS_ASSERT(IsDate(args.thisv()));
 
     RootedObject thisObj(cx, &args.thisv().toObject());
-    if (!CacheLocalTime(&cx->dstOffsetCache, thisObj))
-        return false;
+    FillLocalTimeSlots(&cx->dstOffsetCache, thisObj);
 
     args.rval().set(thisObj->getSlot(JSObject::JSSLOT_DATE_LOCAL_SECONDS));
     return true;
 }
 
 static JSBool
 date_getUTCSeconds(JSContext *cx, unsigned argc, Value *vp)
 {