[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
sullivan
sullivan at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 05:57:49 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit cc1ad25c21563bd9b885cb8f98498c7a1f704140
Author: sullivan <sullivan at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Mar 18 17:40:53 2002 +0000
* prepare-ChangeLog: use ${cvs_command} rather than
cvs in new update line; makes it work on appecvs-encrusted
Jaguars again.
Imposed age limit on history items saved to/loaded from disk.
Sped up history loading by reversing list before processing entries.
* History.subproj/IFWebHistoryPrivate.m:
(+[IFWebHistoryPrivate initialize]): Register default for age limit.
(-[IFWebHistoryPrivate _ageLimitDate]): New convenience method, returns a date older
than any history entry that should be stored/loaded.
(-[IFWebHistoryPrivate arrayRepresentation]): skip too-old dates.
(-[IFWebHistoryPrivate _loadHistoryGuts:]), (-[IFWebHistoryPrivate _saveHistoryGuts:]):
Broke into separate methods to make timing wrapper less messy. Respect age limit.
Report number of items saved/loaded in timing message.
(-[IFWebHistoryPrivate loadHistory]), (-[IFWebHistoryPrivate saveHistory]):
use broken-out _guts methods.
* WebKit.pbproj/project.pbxproj: version wars
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@772 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 7312f1c..c636763 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,20 @@
+2002-03-18 John Sullivan <sullivan at apple.com>
+
+ Imposed age limit on history items saved to/loaded from disk.
+ Sped up history loading by reversing list before processing entries.
+
+ * History.subproj/IFWebHistoryPrivate.m:
+ (+[IFWebHistoryPrivate initialize]): Register default for age limit.
+ (-[IFWebHistoryPrivate _ageLimitDate]): New convenience method, returns a date older
+ than any history entry that should be stored/loaded.
+ (-[IFWebHistoryPrivate arrayRepresentation]): skip too-old dates.
+ (-[IFWebHistoryPrivate _loadHistoryGuts:]), (-[IFWebHistoryPrivate _saveHistoryGuts:]):
+ Broke into separate methods to make timing wrapper less messy. Respect age limit.
+ Report number of items saved/loaded in timing message.
+ (-[IFWebHistoryPrivate loadHistory]), (-[IFWebHistoryPrivate saveHistory]):
+ use broken-out _guts methods.
+ * WebKit.pbproj/project.pbxproj: version wars
+
2002-03-16 Richard Williamson <rjw at apple.com>
Fixed scroll bar flash. Add provisional view to go along with
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index 7312f1c..c636763 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,20 @@
+2002-03-18 John Sullivan <sullivan at apple.com>
+
+ Imposed age limit on history items saved to/loaded from disk.
+ Sped up history loading by reversing list before processing entries.
+
+ * History.subproj/IFWebHistoryPrivate.m:
+ (+[IFWebHistoryPrivate initialize]): Register default for age limit.
+ (-[IFWebHistoryPrivate _ageLimitDate]): New convenience method, returns a date older
+ than any history entry that should be stored/loaded.
+ (-[IFWebHistoryPrivate arrayRepresentation]): skip too-old dates.
+ (-[IFWebHistoryPrivate _loadHistoryGuts:]), (-[IFWebHistoryPrivate _saveHistoryGuts:]):
+ Broke into separate methods to make timing wrapper less messy. Respect age limit.
+ Report number of items saved/loaded in timing message.
+ (-[IFWebHistoryPrivate loadHistory]), (-[IFWebHistoryPrivate saveHistory]):
+ use broken-out _guts methods.
+ * WebKit.pbproj/project.pbxproj: version wars
+
2002-03-16 Richard Williamson <rjw at apple.com>
Fixed scroll bar flash. Add provisional view to go along with
diff --git a/WebKit/History.subproj/IFWebHistoryPrivate.m b/WebKit/History.subproj/IFWebHistoryPrivate.m
index 3f223e8..63cd21d 100644
--- a/WebKit/History.subproj/IFWebHistoryPrivate.m
+++ b/WebKit/History.subproj/IFWebHistoryPrivate.m
@@ -22,7 +22,10 @@
+ (void)initialize
{
[[NSUserDefaults standardUserDefaults] registerDefaults:
- [NSDictionary dictionaryWithObject: @"1000" forKey: @"WebKitHistoryItemLimit"]];
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ @"1000", @"WebKitHistoryItemLimit",
+ @"7", @"WebKitHistoryAgeInDaysLimit",
+ nil]];
}
- (id)initWithFile: (NSString *)file
@@ -247,15 +250,33 @@
#pragma mark ARCHIVING/UNARCHIVING
+// Return a date that marks the age limit for history entries saved to or
+// loaded from disk. Any entry on this day or older should be rejected,
+// as tested with -[NSCalendarDate compareDay:]
+- (NSCalendarDate *)_ageLimitDate
+{
+ int ageInDaysLimit;
+
+ ageInDaysLimit = [[NSUserDefaults standardUserDefaults] integerForKey: @"WebKitHistoryAgeInDaysLimit"];
+ return [[NSCalendarDate calendarDate] dateByAddingYears:0 months:0 days:-ageInDaysLimit
+ hours:0 minutes:0 seconds:0];
+}
+
+// Return a flat array of IFURIEntries. Leaves out entries older than the age limit.
+// Stops filling array when item count limit is reached, even if there are currently
+// more entries than that.
- (NSArray *)arrayRepresentation
{
int dateCount, dateIndex;
- int limit, totalSoFar;
+ int limit;
+ int totalSoFar;
NSMutableArray *arrayRep;
+ NSCalendarDate *ageLimitDate;
arrayRep = [NSMutableArray array];
limit = [[NSUserDefaults standardUserDefaults] integerForKey: @"WebKitHistoryItemLimit"];
+ ageLimitDate = [self _ageLimitDate];
totalSoFar = 0;
dateCount = [_entriesByDate count];
@@ -263,6 +284,11 @@
int entryCount, entryIndex;
NSArray *entries;
+ // skip remaining days if they are older than the age limit
+ if ([[_datesWithEntries objectAtIndex:dateIndex] compareDay:ageLimitDate] != NSOrderedDescending) {
+ break;
+ }
+
entries = [_entriesByDate objectAtIndex:dateIndex];
entryCount = [entries count];
for (entryIndex = 0; entryIndex < entryCount; ++entryIndex) {
@@ -281,80 +307,121 @@
return _file;
}
-- (BOOL)loadHistory
+- (BOOL)_loadHistoryGuts: (int *)numberOfItemsLoaded
{
NSString *path;
NSArray *array;
- int index, count;
+ NSEnumerator *enumerator;
+ NSObject *object;
+ int index;
int limit;
- double start, duration;
- BOOL result;
+ NSCalendarDate *ageLimitDate;
+ BOOL ageLimitPassed;
- start = CFAbsoluteTimeGetCurrent();
- result = YES;
+ *numberOfItemsLoaded = 0;
path = [self file];
if (path == nil) {
WEBKITDEBUG("couldn't load history; couldn't find or create directory to store it in\n");
- result = NO;
- } else {
- array = [NSArray arrayWithContentsOfFile: path];
- if (array == nil) {
- if (![[NSFileManager defaultManager] fileExistsAtPath: path]) {
- WEBKITDEBUG1("no history file found at %s\n",
- DEBUG_OBJECT(path));
- } else {
- WEBKITDEBUG1("attempt to read history from %s failed; perhaps contents are corrupted\n",
- DEBUG_OBJECT(path));
- }
- result = NO;
+ return NO;
+ }
+
+ array = [NSArray arrayWithContentsOfFile: path];
+ if (array == nil) {
+ if (![[NSFileManager defaultManager] fileExistsAtPath: path]) {
+ WEBKITDEBUG1("no history file found at %s\n",
+ DEBUG_OBJECT(path));
} else {
- count = [array count];
- limit = [[NSUserDefaults standardUserDefaults] integerForKey: @"WebKitHistoryItemLimit"];
- count = MIN(count, limit);
- for (index = 0; index < count; ++index) {
- IFURIEntry *entry = [[IFURIEntry alloc] initFromDictionaryRepresentation:
- [array objectAtIndex: index]];
- [self addEntry: entry];
+ WEBKITDEBUG1("attempt to read history from %s failed; perhaps contents are corrupted\n",
+ DEBUG_OBJECT(path));
+ }
+ return NO;
+ }
+
+ limit = [[NSUserDefaults standardUserDefaults] integerForKey: @"WebKitHistoryItemLimit"];
+ ageLimitDate = [self _ageLimitDate];
+ index = 0;
+ // reverse dates so you're loading the oldest first, to minimize the number of comparisons
+ enumerator = [array reverseObjectEnumerator];
+ ageLimitPassed = NO;
+
+ while ((object = [enumerator nextObject]) != nil) {
+ IFURIEntry *entry;
+
+ entry = [[IFURIEntry alloc] initFromDictionaryRepresentation: (NSDictionary *)object];
+
+ // test against date limit
+ if (!ageLimitPassed) {
+ if ([[entry lastVisitedDate] compareDay:ageLimitDate] != NSOrderedDescending) {
+ continue;
+ } else {
+ ageLimitPassed = YES;
}
}
+
+ [self addEntry: entry];
+ if (++index >= limit) {
+ break;
+ }
}
+ *numberOfItemsLoaded = MIN(index, limit);
+ return YES;
+}
+
+- (BOOL)loadHistory
+{
+ int numberOfItems;
+ double start, duration;
+ BOOL result;
+
+ start = CFAbsoluteTimeGetCurrent();
+ result = [self _loadHistoryGuts: &numberOfItems];
+
if (result == YES) {
duration = CFAbsoluteTimeGetCurrent() - start;
- WEBKITDEBUGLEVEL2 (WEBKIT_LOG_TIMING, "loading history from %s took %f seconds\n",
- DEBUG_OBJECT([self file]), duration);
+ WEBKITDEBUGLEVEL3 (WEBKIT_LOG_TIMING, "loading %d history entries from %s took %f seconds\n",
+ numberOfItems, DEBUG_OBJECT([self file]), duration);
}
return result;
}
-- (BOOL)saveHistory
+- (BOOL)_saveHistoryGuts: (int *)numberOfItemsSaved
{
NSString *path;
NSArray *array;
- double start, duration;
- BOOL result;
+ *numberOfItemsSaved = 0;
- start = CFAbsoluteTimeGetCurrent();
- result = YES;
-
path = [self file];
if (path == nil) {
WEBKITDEBUG("couldn't save history; couldn't find or create directory to store it in\n");
- result = NO;
- } else {
- array = [self arrayRepresentation];
- if (![array writeToFile:path atomically:YES]) {
- WEBKITDEBUG2("attempt to save %s to %s failed\n", DEBUG_OBJECT(array), DEBUG_OBJECT(path));
- result = NO;
- }
+ return NO;
+ }
+
+ array = [self arrayRepresentation];
+ if (![array writeToFile:path atomically:YES]) {
+ WEBKITDEBUG2("attempt to save %s to %s failed\n", DEBUG_OBJECT(array), DEBUG_OBJECT(path));
+ return NO;
}
+
+ *numberOfItemsSaved = [array count];
+ return YES;
+}
+
+- (BOOL)saveHistory
+{
+ int numberOfItems;
+ double start, duration;
+ BOOL result;
+
+ start = CFAbsoluteTimeGetCurrent();
+ result = [self _saveHistoryGuts: &numberOfItems];
if (result == YES) {
duration = CFAbsoluteTimeGetCurrent() - start;
- WEBKITDEBUGLEVEL2 (WEBKIT_LOG_TIMING, "saving history to %s took %f seconds\n",
- DEBUG_OBJECT([self file]), duration);
+ WEBKITDEBUGLEVEL3 (WEBKIT_LOG_TIMING, "saving %d history entries to %s took %f seconds\n",
+ numberOfItems, DEBUG_OBJECT([self file]), duration);
}
return result;
diff --git a/WebKit/History.subproj/WebHistoryPrivate.m b/WebKit/History.subproj/WebHistoryPrivate.m
index 3f223e8..63cd21d 100644
--- a/WebKit/History.subproj/WebHistoryPrivate.m
+++ b/WebKit/History.subproj/WebHistoryPrivate.m
@@ -22,7 +22,10 @@
+ (void)initialize
{
[[NSUserDefaults standardUserDefaults] registerDefaults:
- [NSDictionary dictionaryWithObject: @"1000" forKey: @"WebKitHistoryItemLimit"]];
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ @"1000", @"WebKitHistoryItemLimit",
+ @"7", @"WebKitHistoryAgeInDaysLimit",
+ nil]];
}
- (id)initWithFile: (NSString *)file
@@ -247,15 +250,33 @@
#pragma mark ARCHIVING/UNARCHIVING
+// Return a date that marks the age limit for history entries saved to or
+// loaded from disk. Any entry on this day or older should be rejected,
+// as tested with -[NSCalendarDate compareDay:]
+- (NSCalendarDate *)_ageLimitDate
+{
+ int ageInDaysLimit;
+
+ ageInDaysLimit = [[NSUserDefaults standardUserDefaults] integerForKey: @"WebKitHistoryAgeInDaysLimit"];
+ return [[NSCalendarDate calendarDate] dateByAddingYears:0 months:0 days:-ageInDaysLimit
+ hours:0 minutes:0 seconds:0];
+}
+
+// Return a flat array of IFURIEntries. Leaves out entries older than the age limit.
+// Stops filling array when item count limit is reached, even if there are currently
+// more entries than that.
- (NSArray *)arrayRepresentation
{
int dateCount, dateIndex;
- int limit, totalSoFar;
+ int limit;
+ int totalSoFar;
NSMutableArray *arrayRep;
+ NSCalendarDate *ageLimitDate;
arrayRep = [NSMutableArray array];
limit = [[NSUserDefaults standardUserDefaults] integerForKey: @"WebKitHistoryItemLimit"];
+ ageLimitDate = [self _ageLimitDate];
totalSoFar = 0;
dateCount = [_entriesByDate count];
@@ -263,6 +284,11 @@
int entryCount, entryIndex;
NSArray *entries;
+ // skip remaining days if they are older than the age limit
+ if ([[_datesWithEntries objectAtIndex:dateIndex] compareDay:ageLimitDate] != NSOrderedDescending) {
+ break;
+ }
+
entries = [_entriesByDate objectAtIndex:dateIndex];
entryCount = [entries count];
for (entryIndex = 0; entryIndex < entryCount; ++entryIndex) {
@@ -281,80 +307,121 @@
return _file;
}
-- (BOOL)loadHistory
+- (BOOL)_loadHistoryGuts: (int *)numberOfItemsLoaded
{
NSString *path;
NSArray *array;
- int index, count;
+ NSEnumerator *enumerator;
+ NSObject *object;
+ int index;
int limit;
- double start, duration;
- BOOL result;
+ NSCalendarDate *ageLimitDate;
+ BOOL ageLimitPassed;
- start = CFAbsoluteTimeGetCurrent();
- result = YES;
+ *numberOfItemsLoaded = 0;
path = [self file];
if (path == nil) {
WEBKITDEBUG("couldn't load history; couldn't find or create directory to store it in\n");
- result = NO;
- } else {
- array = [NSArray arrayWithContentsOfFile: path];
- if (array == nil) {
- if (![[NSFileManager defaultManager] fileExistsAtPath: path]) {
- WEBKITDEBUG1("no history file found at %s\n",
- DEBUG_OBJECT(path));
- } else {
- WEBKITDEBUG1("attempt to read history from %s failed; perhaps contents are corrupted\n",
- DEBUG_OBJECT(path));
- }
- result = NO;
+ return NO;
+ }
+
+ array = [NSArray arrayWithContentsOfFile: path];
+ if (array == nil) {
+ if (![[NSFileManager defaultManager] fileExistsAtPath: path]) {
+ WEBKITDEBUG1("no history file found at %s\n",
+ DEBUG_OBJECT(path));
} else {
- count = [array count];
- limit = [[NSUserDefaults standardUserDefaults] integerForKey: @"WebKitHistoryItemLimit"];
- count = MIN(count, limit);
- for (index = 0; index < count; ++index) {
- IFURIEntry *entry = [[IFURIEntry alloc] initFromDictionaryRepresentation:
- [array objectAtIndex: index]];
- [self addEntry: entry];
+ WEBKITDEBUG1("attempt to read history from %s failed; perhaps contents are corrupted\n",
+ DEBUG_OBJECT(path));
+ }
+ return NO;
+ }
+
+ limit = [[NSUserDefaults standardUserDefaults] integerForKey: @"WebKitHistoryItemLimit"];
+ ageLimitDate = [self _ageLimitDate];
+ index = 0;
+ // reverse dates so you're loading the oldest first, to minimize the number of comparisons
+ enumerator = [array reverseObjectEnumerator];
+ ageLimitPassed = NO;
+
+ while ((object = [enumerator nextObject]) != nil) {
+ IFURIEntry *entry;
+
+ entry = [[IFURIEntry alloc] initFromDictionaryRepresentation: (NSDictionary *)object];
+
+ // test against date limit
+ if (!ageLimitPassed) {
+ if ([[entry lastVisitedDate] compareDay:ageLimitDate] != NSOrderedDescending) {
+ continue;
+ } else {
+ ageLimitPassed = YES;
}
}
+
+ [self addEntry: entry];
+ if (++index >= limit) {
+ break;
+ }
}
+ *numberOfItemsLoaded = MIN(index, limit);
+ return YES;
+}
+
+- (BOOL)loadHistory
+{
+ int numberOfItems;
+ double start, duration;
+ BOOL result;
+
+ start = CFAbsoluteTimeGetCurrent();
+ result = [self _loadHistoryGuts: &numberOfItems];
+
if (result == YES) {
duration = CFAbsoluteTimeGetCurrent() - start;
- WEBKITDEBUGLEVEL2 (WEBKIT_LOG_TIMING, "loading history from %s took %f seconds\n",
- DEBUG_OBJECT([self file]), duration);
+ WEBKITDEBUGLEVEL3 (WEBKIT_LOG_TIMING, "loading %d history entries from %s took %f seconds\n",
+ numberOfItems, DEBUG_OBJECT([self file]), duration);
}
return result;
}
-- (BOOL)saveHistory
+- (BOOL)_saveHistoryGuts: (int *)numberOfItemsSaved
{
NSString *path;
NSArray *array;
- double start, duration;
- BOOL result;
+ *numberOfItemsSaved = 0;
- start = CFAbsoluteTimeGetCurrent();
- result = YES;
-
path = [self file];
if (path == nil) {
WEBKITDEBUG("couldn't save history; couldn't find or create directory to store it in\n");
- result = NO;
- } else {
- array = [self arrayRepresentation];
- if (![array writeToFile:path atomically:YES]) {
- WEBKITDEBUG2("attempt to save %s to %s failed\n", DEBUG_OBJECT(array), DEBUG_OBJECT(path));
- result = NO;
- }
+ return NO;
+ }
+
+ array = [self arrayRepresentation];
+ if (![array writeToFile:path atomically:YES]) {
+ WEBKITDEBUG2("attempt to save %s to %s failed\n", DEBUG_OBJECT(array), DEBUG_OBJECT(path));
+ return NO;
}
+
+ *numberOfItemsSaved = [array count];
+ return YES;
+}
+
+- (BOOL)saveHistory
+{
+ int numberOfItems;
+ double start, duration;
+ BOOL result;
+
+ start = CFAbsoluteTimeGetCurrent();
+ result = [self _saveHistoryGuts: &numberOfItems];
if (result == YES) {
duration = CFAbsoluteTimeGetCurrent() - start;
- WEBKITDEBUGLEVEL2 (WEBKIT_LOG_TIMING, "saving history to %s took %f seconds\n",
- DEBUG_OBJECT([self file]), duration);
+ WEBKITDEBUGLEVEL3 (WEBKIT_LOG_TIMING, "saving %d history entries to %s took %f seconds\n",
+ numberOfItems, DEBUG_OBJECT([self file]), duration);
}
return result;
diff --git a/WebKit/WebKit.pbproj/project.pbxproj b/WebKit/WebKit.pbproj/project.pbxproj
index bb86de4..f971a57 100644
--- a/WebKit/WebKit.pbproj/project.pbxproj
+++ b/WebKit/WebKit.pbproj/project.pbxproj
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 34;
+ objectVersion = 36;
objects = {
014CEA440018CDF011CA2923 = {
buildRules = (
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list