* Don't have -[AIChat containedObjects] return copy/autoreleased array. It confuses my memory management tracking and is unnecessarily inefficient when the most common use case uses it without mutation of the chat.
authorEvan Schoenberg
Mon, 22 Aug 2011 21:11:40 -0500
changeset 3627 6431098c625a
parent 3626 f451e4eb43ee
child 3628 b702c5f10d91
* Don't have -[AIChat containedObjects] return copy/autoreleased array. It confuses my memory management tracking and is unnecessarily inefficient when the most common use case uses it without mutation of the chat.
* Fix a logic error I introduced in a previous commit in -[AIChat removeAllParticipatingContactsSilently] and added a comment to avoid future confusion in the same way
* Change a copy/autorelease into copy/.../release, again to simplify memory management tracking
(transplanted from 6091a858e33c6d6c4788722117274dc5c2d3b956)
Frameworks/Adium Framework/Source/AIChat.m
--- a/Frameworks/Adium Framework/Source/AIChat.m	Mon Aug 22 21:09:06 2011 -0500
+++ b/Frameworks/Adium Framework/Source/AIChat.m	Mon Aug 22 21:11:40 2011 -0500
@@ -411,7 +411,7 @@
 
 - (void)addParticipatingListObjects:(NSArray *)inObjects notify:(BOOL)notify
 {
-	NSMutableArray *contacts = [[inObjects mutableCopy] autorelease];
+	NSMutableArray *contacts = [inObjects mutableCopy];
 
 	for (AIListObject *obj in inObjects) {
 		if ([self containsObject:obj] || ![self canContainObject:obj])
@@ -420,6 +420,7 @@
 	
 	[participatingContacts addObjectsFromArray:contacts];
 	[adium.chatController chat:self addedListContacts:contacts notify:notify];
+	[contacts release];
 }
 
 // Invite a list object to join the chat. Returns YES if the chat joins, NO otherwise
@@ -615,14 +616,13 @@
 }
 
 #pragma mark AIContainingObject protocol
-//AIContainingObject protocol
 - (NSArray *)visibleContainedObjects
 {
 	return self.containedObjects;
 }
 - (NSArray *)containedObjects
 {
-	return [[participatingContacts copy] autorelease];
+	return participatingContacts;
 }
 - (NSUInteger)countOfContainedObjects
 {
@@ -696,18 +696,19 @@
 
 - (void)removeAllParticipatingContactsSilently
 {
-    [participatingContacts removeAllObjects];
-	[participatingContactsFlags removeAllObjects];
-	[participatingContactsAliases removeAllObjects];
-
+	/* Note that allGroupChatsContainingContact won't count this chat if it's already marked as not open */
 	for (AIListContact *listContact in self) {
 		if (listContact.isStranger &&
 			![adium.chatController existingChatWithContact:listContact.parentContact] &&
-			![adium.chatController allGroupChatsContainingContact:listContact.parentContact].count) {
+			([adium.chatController allGroupChatsContainingContact:listContact.parentContact].count == 0)) {
 			[adium.contactController accountDidStopTrackingContact:listContact];
 		}
 	}
 
+	[participatingContacts removeAllObjects];
+	[participatingContactsFlags removeAllObjects];
+	[participatingContactsAliases removeAllObjects];
+
 	[[NSNotificationCenter defaultCenter] postNotificationName:Chat_ParticipatingListObjectsChanged
 											  object:self];
 }