Changeset 31937 in webkit for trunk/JavaScriptCore/kjs/DateMath.h


Ignore:
Timestamp:
Apr 16, 2008, 2:41:23 AM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Adam Roben.

Cache Gregorian date/time structure on DateInstance objects for 1.027x SunSpider speedup
(1.65x on date-format-xparb, 1.13x on date-format-tofte).

  • kjs/DateMath.h: (KJS::GregorianDateTime::copyFrom): Added. It presumably makes sense to keep GregorianDateTime Noncopiable, so it's not just operator=.
  • kjs/date_object.h: Added a per-object cache.
  • kjs/date_object.cpp: (KJS::DateInstance::DateInstance): (KJS::DateInstance::msToGregorianDateTime): (KJS::dateProtoFuncToString): (KJS::dateProtoFuncToUTCString): (KJS::dateProtoFuncToDateString): (KJS::dateProtoFuncToTimeString): (KJS::dateProtoFuncToLocaleString): (KJS::dateProtoFuncToLocaleDateString): (KJS::dateProtoFuncToLocaleTimeString): (KJS::dateProtoFuncGetFullYear): (KJS::dateProtoFuncGetUTCFullYear): (KJS::dateProtoFuncToGMTString): (KJS::dateProtoFuncGetMonth): (KJS::dateProtoFuncGetUTCMonth): (KJS::dateProtoFuncGetDate): (KJS::dateProtoFuncGetUTCDate): (KJS::dateProtoFuncGetDay): (KJS::dateProtoFuncGetUTCDay): (KJS::dateProtoFuncGetHours): (KJS::dateProtoFuncGetUTCHours): (KJS::dateProtoFuncGetMinutes): (KJS::dateProtoFuncGetUTCMinutes): (KJS::dateProtoFuncGetSeconds): (KJS::dateProtoFuncGetUTCSeconds): (KJS::dateProtoFuncGetTimezoneOffset): (KJS::setNewValueFromTimeArgs): (KJS::setNewValueFromDateArgs): (KJS::dateProtoFuncSetYear): (KJS::dateProtoFuncGetYear): Use the cache when converting.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/DateMath.h

    r31813 r31937  
    9393        delete [] timeZone;
    9494    }
    95    
     95
    9696    GregorianDateTime(const tm& inTm)
    9797        : second(inTm.tm_sec)
     
    140140    }
    141141
     142    void copyFrom(const GregorianDateTime& rhs)
     143    {
     144        second = rhs.second;
     145        minute = rhs.minute;
     146        hour = rhs.hour;
     147        weekDay = rhs.weekDay;
     148        monthDay = rhs.monthDay;
     149        yearDay = rhs.yearDay;
     150        month = rhs.month;
     151        year = rhs.year;
     152        isDST = rhs.isDST;
     153        utcOffset = rhs.utcOffset;
     154        if (rhs.timeZone) {
     155            int inZoneSize = strlen(rhs.timeZone) + 1;
     156            timeZone = new char[inZoneSize];
     157            strncpy(timeZone, rhs.timeZone, inZoneSize);
     158        } else
     159            timeZone = 0;
     160    }
     161
    142162    int second;
    143163    int minute;
Note: See TracChangeset for help on using the changeset viewer.