adium 2475:cdf9e421d6e8: Cache the 'online' value in AIListObjec...
commits at adium.im
commits at adium.im
Wed Jun 10 04:51:11 UTC 2009
details: http://hg.adium.im/adium/rev/cdf9e421d6e8
revision: 2475:cdf9e421d6e8
author: David Smith <catfish.man at gmail.com>
date: Tue Jun 09 21:51:02 2009 -0700
Cache the 'online' value in AIListObject, speeding up status_sort by 20% or so
diffs (193 lines):
diff -r c56975e58200 -r cdf9e421d6e8 Frameworks/Adium Framework/Source/AIAbstractAccount.m
--- a/Frameworks/Adium Framework/Source/AIAbstractAccount.m Tue Jun 09 16:32:31 2009 -0700
+++ b/Frameworks/Adium Framework/Source/AIAbstractAccount.m Tue Jun 09 21:51:02 2009 -0700
@@ -463,7 +463,7 @@
*/
- (void)updateCommonStatusForKey:(NSString *)key
{
- BOOL areOnline = [self boolValueForProperty:@"Online"];
+ BOOL areOnline = self.online;
//Online status changed
//Call connect or disconnect as appropriate
@@ -651,7 +651,7 @@
- (AIStatus *)statusState
{
- if ([self boolValueForProperty:@"Online"]) {
+ if (self.online) {
AIStatus *statusState = [self valueForProperty:@"StatusState"];
if (!statusState) {
statusState = [adium.statusController defaultInitialStatusState];
@@ -742,7 +742,7 @@
forProperty:@"Prompt For Password On Next Connect"
notify:NotifyNever];
- if (![self boolValueForProperty:@"Online"] && ![self valueForProperty:@"Connecting"]) {
+ if (!self.online && ![self valueForProperty:@"Connecting"]) {
[self setPasswordTemporarily:inPassword];
//Time to connect!
@@ -1308,7 +1308,7 @@
- (void)didDisconnect
{
//If we were online, display a status message in all of our open chats noting our disconnection
- if ([self boolValueForProperty:@"Online"]) {
+ if (self.online) {
for (AIChat *chat in adium.interfaceController.openChats) {
if (chat.account != self || !chat.isOpen)
continue;
diff -r c56975e58200 -r cdf9e421d6e8 Frameworks/Adium Framework/Source/AIListContact.m
--- a/Frameworks/Adium Framework/Source/AIListContact.m Tue Jun 09 16:32:31 2009 -0700
+++ b/Frameworks/Adium Framework/Source/AIListContact.m Tue Jun 09 21:51:02 2009 -0700
@@ -342,8 +342,8 @@
{
if (online != self.online) {
[self setValue:[NSNumber numberWithBool:online]
- forProperty:@"Online"
- notify:notify];
+ forProperty:@"Online"
+ notify:notify];
if (!silent) {
[self setValue:[NSNumber numberWithBool:YES]
diff -r c56975e58200 -r cdf9e421d6e8 Frameworks/Adium Framework/Source/AIListObject.h
--- a/Frameworks/Adium Framework/Source/AIListObject.h Tue Jun 09 16:32:31 2009 -0700
+++ b/Frameworks/Adium Framework/Source/AIListObject.h Tue Jun 09 21:51:02 2009 -0700
@@ -90,6 +90,8 @@
CGFloat cachedSmallestOrder;
CGFloat cachedLargestOrder;
+
+ BOOL m_online;
}
- (id)initWithUID:(NSString *)inUID service:(AIService *)inService;
diff -r c56975e58200 -r cdf9e421d6e8 Frameworks/Adium Framework/Source/AIListObject.m
--- a/Frameworks/Adium Framework/Source/AIListObject.m Tue Jun 09 16:32:31 2009 -0700
+++ b/Frameworks/Adium Framework/Source/AIListObject.m Tue Jun 09 21:51:02 2009 -0700
@@ -624,9 +624,16 @@
if (notify) [self notifyOfChangedPropertiesSilently:NO];
}
+- (void) setValue:(id)value forProperty:(NSString *)key notify:(NotifyTiming)notify
+{
+ if ([key isEqualToString:@"Online"])
+ m_online = value ? [value boolValue] : NO;
+ [super setValue:value forProperty:key notify:notify];
+}
+
- (BOOL)online
{
- return [self boolValueForProperty:@"Online"];
+ return m_online;
}
- (AIStatusSummary)statusSummary
diff -r c56975e58200 -r cdf9e421d6e8 Plugins/Bonjour/AWBonjourAccount.m
--- a/Plugins/Bonjour/AWBonjourAccount.m Tue Jun 09 16:32:31 2009 -0700
+++ b/Plugins/Bonjour/AWBonjourAccount.m Tue Jun 09 21:51:02 2009 -0700
@@ -382,7 +382,7 @@
- (void)updateStatusForKey:(NSString *)key
{
[super updateStatusForKey:key];
- BOOL areOnline = [[self valueForProperty:@"Online"] boolValue];
+ BOOL areOnline = self.online;
//Now look at keys which only make sense while online
if (areOnline) {
diff -r c56975e58200 -r cdf9e421d6e8 Plugins/Contact Status Dock Overlays/AIContactStatusDockOverlaysPlugin.m
--- a/Plugins/Contact Status Dock Overlays/AIContactStatusDockOverlaysPlugin.m Tue Jun 09 16:32:31 2009 -0700
+++ b/Plugins/Contact Status Dock Overlays/AIContactStatusDockOverlaysPlugin.m Tue Jun 09 21:51:02 2009 -0700
@@ -256,23 +256,22 @@
- (NSSet *)updateListObject:(AIListObject *)inObject keys:(NSSet *)inModifiedKeys silent:(BOOL)silent
{
- if ([inObject isKindOfClass:[AIAccount class]]) {
- //When an account signs on or off, force an overlay update as it may have silently changed
- //contacts' statuses
- if ([inModifiedKeys containsObject:@"Online"]) {
- BOOL madeChanges = NO;
-
- for (AIListObject *listObject in [[overlayObjectsArray copy] autorelease]) {
- if (([listObject respondsToSelector:@selector(account)]) &&
- ([(id)listObject account] == inObject) &&
- ([overlayObjectsArray containsObjectIdenticalTo:listObject])) {
- [overlayObjectsArray removeObject:listObject];
- madeChanges = YES;
- }
+ //When an account signs on or off, force an overlay update as it may have silently changed
+ //contacts' statuses
+ if ([inObject isKindOfClass:[AIAccount class]] && [inModifiedKeys containsObject:@"Online"]) {
+
+ BOOL madeChanges = NO;
+
+ for (AIListObject *listObject in [[overlayObjectsArray copy] autorelease]) {
+ if (([listObject respondsToSelector:@selector(account)]) &&
+ ([(id)listObject account] == inObject) &&
+ ([overlayObjectsArray containsObjectIdenticalTo:listObject])) {
+ [overlayObjectsArray removeObject:listObject];
+ madeChanges = YES;
}
-
- if (madeChanges) [self _setOverlay];
}
+
+ if (madeChanges) [self _setOverlay];
}
return nil;
diff -r c56975e58200 -r cdf9e421d6e8 Source/AIAccountListPreferences.m
--- a/Source/AIAccountListPreferences.m Tue Jun 09 16:32:31 2009 -0700
+++ b/Source/AIAccountListPreferences.m Tue Jun 09 21:51:02 2009 -0700
@@ -694,7 +694,7 @@
if ([account valueForProperty:@"ConnectionProgressString"] && [account boolValueForProperty:@"Connecting"]) {
// Connection status if we're currently connecting, with the percent at the end
statusMessage = [[account valueForProperty:@"ConnectionProgressString"] stringByAppendingFormat:@" (%2.f%%)", [[account valueForProperty:@"ConnectionProgressPercent"] doubleValue]*100.0];
- } else if ([account lastDisconnectionError] && ![account boolValueForProperty:@"Online"] && ![account boolValueForProperty:@"Connecting"]) {
+ } else if ([account lastDisconnectionError] && !account.online && ![account boolValueForProperty:@"Connecting"]) {
// If there's an error and we're not online and not connecting
NSMutableString *returnedMessage = [[[account lastDisconnectionError] mutableCopy] autorelease];
@@ -834,7 +834,7 @@
title = AILocalizedString(@"Connecting",nil);
} else if ([account boolValueForProperty:@"Disconnecting"]) {
title = AILocalizedString(@"Disconnecting",nil);
- } else if ([account boolValueForProperty:@"Online"]) {
+ } else if (account.online) {
title = AILocalizedString(@"Online",nil);
//XXX: why is this valueForProperty instead of boolValueForProperty?
@@ -931,7 +931,7 @@
[cell setEnabled:([account boolValueForProperty:@"Connecting"] ||
[account valueForProperty:@"Waiting to Reconnect"] ||
[account boolValueForProperty:@"Disconnecting"] ||
- [account boolValueForProperty:@"Online"])];
+ account.online)];
} else if ([identifier isEqualToString:@"statusicon"]) {
[cell accessibilitySetOverrideValue:@" "
diff -r c56975e58200 -r cdf9e421d6e8 Source/AIContactStatusEventsPlugin.m
--- a/Source/AIContactStatusEventsPlugin.m Tue Jun 09 16:32:31 2009 -0700
+++ b/Source/AIContactStatusEventsPlugin.m Tue Jun 09 21:51:02 2009 -0700
@@ -398,7 +398,7 @@
/* Events which are irrelevent if the contact is not online - these changes occur when we are
* just doing bookkeeping e.g. an away contact signs off, we clear the away flag, but they didn't actually
* come back from away. */
- if ([[inObject numberValueForProperty:@"Online"] boolValue]) {
+ if (inObject.online) {
if ([inModifiedKeys containsObject:@"StatusMessage"] || [inModifiedKeys containsObject:@"StatusType"]) {
NSNumber *newAwayNumber;
NSString *newStatusMessage;
diff -r c56975e58200 -r cdf9e421d6e8 Source/ESAccountEvents.m
--- a/Source/ESAccountEvents.m Tue Jun 09 16:32:31 2009 -0700
+++ b/Source/ESAccountEvents.m Tue Jun 09 21:51:02 2009 -0700
@@ -205,7 +205,7 @@
if ([inObject isKindOfClass:[AIAccount class]]) { //We only care about accounts
if ([inModifiedKeys containsObject:@"Online"]) {
- if ([[inObject numberValueForProperty:@"Online"] boolValue]) {
+ if (inObject.online) {
if (accountConnectionStatusGroupingOnlineTimer) {
[accountConnectionStatusGroupingOnlineTimer invalidate]; [accountConnectionStatusGroupingOnlineTimer release];
}
More information about the commits
mailing list