[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75
darin at apple.com
darin at apple.com
Thu Oct 29 20:32:41 UTC 2009
The following commit has been merged in the webkit-1.1 branch:
commit 332d42059d97006e274d504162c86d003899aa3f
Author: darin at apple.com <darin at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Sep 24 00:33:29 2009 +0000
Speed up access to history items by caching date computation.
Patch by Darin Adler <darin at apple.com> on 2009-09-23
Reviewed by Dan Bernstein.
* History/WebHistory.mm:
(getDayBoundaries): Refactored from timeIntervalForBeginningOfDay.
Returns the beginning of the day that the passed time is within and
the beginning of the next day.
(beginningOfDay): Added. Uses getDayBoundaries so it can be fast for
multiple dates within the same day, which is the common case.
(dateKey): Added. Calls beginningOfDay and converts to an integer.
(-[WebHistoryPrivate findKey:forDay:]): Changed to call dateKey
insetad of timeIntervalForBeginningOfDay.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48689 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 4fb5626..d157ddb 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,19 @@
+2009-09-23 Darin Adler <darin at apple.com>
+
+ Reviewed by Dan Bernstein.
+
+ Speed up access to history items by caching date computation.
+
+ * History/WebHistory.mm:
+ (getDayBoundaries): Refactored from timeIntervalForBeginningOfDay.
+ Returns the beginning of the day that the passed time is within and
+ the beginning of the next day.
+ (beginningOfDay): Added. Uses getDayBoundaries so it can be fast for
+ multiple dates within the same day, which is the common case.
+ (dateKey): Added. Calls beginningOfDay and converts to an integer.
+ (-[WebHistoryPrivate findKey:forDay:]): Changed to call dateKey
+ insetad of timeIntervalForBeginningOfDay.
+
2009-09-23 David Kilzer <ddkilzer at apple.com>
Move definition of USE(PLUGIN_HOST_PROCESS) from WebKitPrefix.h to Platform.h
diff --git a/WebKit/mac/History/WebHistory.mm b/WebKit/mac/History/WebHistory.mm
index e971aba..6304fd2 100644
--- a/WebKit/mac/History/WebHistory.mm
+++ b/WebKit/mac/History/WebHistory.mm
@@ -148,27 +148,42 @@ private:
#pragma mark MODIFYING CONTENTS
-static WebHistoryDateKey timeIntervalForBeginningOfDay(NSTimeInterval interval)
+static void getDayBoundaries(NSTimeInterval interval, NSTimeInterval& beginningOfDay, NSTimeInterval& beginningOfNextDay)
{
CFTimeZoneRef timeZone = CFTimeZoneCopyDefault();
CFGregorianDate date = CFAbsoluteTimeGetGregorianDate(interval, timeZone);
date.hour = 0;
date.minute = 0;
date.second = 0;
- NSTimeInterval result = CFGregorianDateGetAbsoluteTime(date, timeZone);
+ beginningOfDay = CFGregorianDateGetAbsoluteTime(date, timeZone);
+ date.day += 1;
+ beginningOfNextDay = CFGregorianDateGetAbsoluteTime(date, timeZone);
CFRelease(timeZone);
+}
- // Converting from double to int64_t is safe here as NSDate's useful range
- // is -2**48 .. 2**47 which will safely fit in an int64_t.
- return (WebHistoryDateKey)result;
+static inline NSTimeInterval beginningOfDay(NSTimeInterval date)
+{
+ static NSTimeInterval cachedBeginningOfDay = NAN;
+ static NSTimeInterval cachedBeginningOfNextDay;
+ if (!(date >= cachedBeginningOfDay && date < cachedBeginningOfNextDay))
+ getDayBoundaries(date, cachedBeginningOfDay, cachedBeginningOfNextDay);
+ return cachedBeginningOfDay;
+}
+
+static inline WebHistoryDateKey dateKey(NSTimeInterval date)
+{
+ // Converting from double (NSTimeInterval) to int64_t (WebHistoryDateKey) is
+ // safe here because all sensible dates are in the range -2**48 .. 2**47 which
+ // safely fits in an int64_t.
+ return beginningOfDay(date);
}
// Returns whether the day is already in the list of days,
// and fills in *key with the key used to access its location
- (BOOL)findKey:(WebHistoryDateKey*)key forDay:(NSTimeInterval)date
{
- ASSERT_ARG(key, key != nil);
- *key = timeIntervalForBeginningOfDay(date);
+ ASSERT_ARG(key, key);
+ *key = dateKey(date);
return _entriesByDate->contains(*key);
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list