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:
parent
b9df5aa295
commit
67c04c8744
11
src/date.js
11
src/date.js
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user