One element cache for localtime.

Review URL: http://codereview.chromium.org/2023005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4628 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
sandholm@chromium.org 2010-05-10 09:27:37 +00:00
parent b9df5aa295
commit 67c04c8744

View File

@ -238,7 +238,15 @@ function LocalTime(time) {
return time + DaylightSavingsOffset(time) + local_time_offset;
}
var ltcache = {
key: null,
val: null
};
function LocalTimeNoCheck(time) {
var ltc = ltcache;
if (%_ObjectEquals(time, ltc.key)) return ltc.val;
if (time < -MAX_TIME_MS || time > MAX_TIME_MS) {
return $NaN;
}
@ -252,7 +260,8 @@ function LocalTimeNoCheck(time) {
} else {
var dst_offset = DaylightSavingsOffset(time);
}
return time + local_time_offset + dst_offset;
ltc.key = time;
return (ltc.val = time + local_time_offset + dst_offset);
}