[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:34:28 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit 93427bae4147e4a6d872ff7592160ae981e404eb
Author: darin at apple.com <darin at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Sep 25 21:40:50 2009 +0000

    Speed up access to history items by caching date computation.
    
    Patch by Darin Adler <darin at apple.com> on 2009-09-25
    Reviewed by Steve Falkenburg.
    
    * 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.
    (WebHistory::findKey): Changed to call dateKey instead of
    timeIntervalForBeginningOfDay.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48770 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog
index 5d5a9e2..94db91e 100644
--- a/WebKit/win/ChangeLog
+++ b/WebKit/win/ChangeLog
@@ -1,3 +1,19 @@
+2009-09-25  Darin Adler  <darin at apple.com>
+
+        Reviewed by Steve Falkenburg.
+
+        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.
+        (WebHistory::findKey): Changed to call dateKey instead of
+        timeIntervalForBeginningOfDay.
+
 2009-09-25  Adam Roben  <aroben at apple.com>
 
         Add SPI to invalidate a WebView's backing store
diff --git a/WebKit/win/WebHistory.cpp b/WebKit/win/WebHistory.cpp
index 095a74b..854031a 100644
--- a/WebKit/win/WebHistory.cpp
+++ b/WebKit/win/WebHistory.cpp
@@ -855,18 +855,33 @@ HRESULT WebHistory::removeItemFromDateCaches(IWebHistoryItem* entry)
     return hr;
 }
 
-WebHistory::DateKey timeIntervalForBeginningOfDay(CFAbsoluteTime day)
+static void getDayBoundaries(CFAbsoluteTime day, CFAbsoluteTime& beginningOfDay, CFAbsoluteTime& beginningOfNextDay)
 {
     RetainPtr<CFTimeZoneRef> timeZone(AdoptCF, CFTimeZoneCopyDefault());
     CFGregorianDate date = CFAbsoluteTimeGetGregorianDate(day, timeZone.get());
     date.hour = 0;
     date.minute = 0;
     date.second = 0;
-    CFAbsoluteTime result = CFGregorianDateGetAbsoluteTime(date, timeZone.get());
+    beginningOfDay = CFGregorianDateGetAbsoluteTime(date, timeZone.get());
+    date.day += 1;
+    beginningOfNextDay = CFGregorianDateGetAbsoluteTime(date, timeZone.get());
+}
 
-    // 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 static_cast<WebHistory::DateKey>(result);
+static inline CFAbsoluteTime beginningOfDay(CFAbsoluteTime date)
+{
+    static CFAbsoluteTime cachedBeginningOfDay = numeric_limits<CFAbsoluteTime>::quiet_NaN();
+    static CFAbsoluteTime cachedBeginningOfNextDay;
+    if (!(date >= cachedBeginningOfDay && date < cachedBeginningOfNextDay))
+        getDayBoundaries(date, cachedBeginningOfDay, cachedBeginningOfNextDay);
+    return cachedBeginningOfDay;
+}
+
+static inline WebHistory::DateKey dateKey(CFAbsoluteTime date)
+{
+    // Converting from double (CFAbsoluteTime) 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,
@@ -875,7 +890,7 @@ bool WebHistory::findKey(DateKey* key, CFAbsoluteTime forDay)
 {
     ASSERT_ARG(key, key);
 
-    *key = timeIntervalForBeginningOfDay(forDay);
+    *key = dateKey(forDay);
     return m_entriesByDate.contains(*key);
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list