adium 2158:794fe03a1dfa: Changeloggin all night son.

commits at adium.im commits at adium.im
Mon May 11 22:39:57 UTC 2009


details:	http://hg.adium.im/adium/rev/794fe03a1dfa
revision:	2158:794fe03a1dfa
author:		Zachary West <zacw at adium.im>
date:		Mon May 11 18:21:22 2009 -0400

Changeloggin all night son.
Subject: adium 2159:ca64766866d5: Cache the largest and smallest order, updating when appropriate.

details:	http://hg.adium.im/adium/rev/ca64766866d5
revision:	2159:ca64766866d5
author:		Zachary West <zacw at adium.im>
date:		Mon May 11 18:39:40 2009 -0400

Cache the largest and smallest order, updating when appropriate.

diffstat:

 ChangeLogs/Changes.txt                           |   1 +
 Frameworks/Adium Framework/Source/AIListObject.h |   3 +
 Frameworks/Adium Framework/Source/AIListObject.m |  41 +++++++++++++-------
 3 files changed, 30 insertions(+), 15 deletions(-)

diffs (97 lines):

diff -r 4151014b7d97 -r ca64766866d5 ChangeLogs/Changes.txt
--- a/ChangeLogs/Changes.txt	Mon May 11 17:55:43 2009 -0400
+++ b/ChangeLogs/Changes.txt	Mon May 11 18:39:40 2009 -0400
@@ -55,6 +55,7 @@
  * Corrected adding contacts to multiple accounts. The "Add Contact" window was only adding to the existing account.
  * Add account-specific menu items (such as "Initiate Multi-User Chat" or "Initiate Direct IM") to the main Contact menu.
  * Corrected a bug where a combined contact would be "always visible" and toggling the preference would not unset it.
+ * Fixed deleting a group not removing its contents.
 
 Logging
  * You can now replace Logs folder with an alias to another folder (on, say, an encrypted disk image). (#992)
diff -r 4151014b7d97 -r ca64766866d5 Frameworks/Adium Framework/Source/AIListObject.h
--- a/Frameworks/Adium Framework/Source/AIListObject.h	Mon May 11 17:55:43 2009 -0400
+++ b/Frameworks/Adium Framework/Source/AIListObject.h	Mon May 11 18:39:40 2009 -0400
@@ -88,6 +88,9 @@
 
 	//Grouping, Manual ordering
 	NSMutableSet *m_groups; //The AIContainingObjects that this object is in; currently always has only 1
+	
+	CGFloat				cachedSmallestOrder;
+	CGFloat				cachedLargestOrder;
 }
 
 - (id)initWithUID:(NSString *)inUID service:(AIService *)inService;
diff -r 4151014b7d97 -r ca64766866d5 Frameworks/Adium Framework/Source/AIListObject.m
--- a/Frameworks/Adium Framework/Source/AIListObject.m	Mon May 11 17:55:43 2009 -0400
+++ b/Frameworks/Adium Framework/Source/AIListObject.m	Mon May 11 18:39:40 2009 -0400
@@ -38,6 +38,7 @@
 @interface AIListObject ()
 - (void)setContainingGroup:(AIListGroup *)inGroup;
 - (void)setupObservedValues;
+- (void)updateOrderCache;
 @end
 
 /*!
@@ -712,6 +713,8 @@
 	[self setPreference:newDict
 				 forKey:@"OrderIndexDictionary"
 				  group:ObjectStatusCache];
+	
+	[self updateOrderCache];
 }
 
 //Order index
@@ -736,29 +739,37 @@
 	return orderIndexForObject;
 }
 
-- (float)smallestOrder
+- (CGFloat)smallestOrder
 {
-	float smallest = INFINITY;
+	if (!cachedSmallestOrder) {
+		[self updateOrderCache];
+	}
+
+	return cachedSmallestOrder;
+}
+
+- (CGFloat)largestOrder
+{
+	if (!cachedLargestOrder) {
+		[self updateOrderCache];
+	}
+	
+	return cachedLargestOrder;	
+}
+
+- (void)updateOrderCache
+{
+	CGFloat smallest = INFINITY, largest = 0;
+	
 	NSDictionary *orderIndex = [self preferenceForKey:@"OrderIndexDictionary" group:ObjectStatusCache];
 	
 	for (NSNumber *index in orderIndex.allValues) {
 		smallest = MIN(smallest, index.floatValue);
-	}
-	
-	return smallest;
-}
-
-- (float)largestOrder
-{
-	float largest = 0;
-	
-	NSDictionary *orderIndex = [self preferenceForKey:@"OrderIndexDictionary" group:ObjectStatusCache];
-	
-	for (NSNumber *index in orderIndex.allValues) {
 		largest = MAX(largest, index.floatValue);
 	}
 	
-	return largest;
+	cachedSmallestOrder = smallest;
+	cachedLargestOrder = largest;
 }
 
 #pragma mark Comparison




More information about the commits mailing list