adium 2104:03c251eb0963: Fast enumerate, etc...

commits at adium.im commits at adium.im
Thu May 7 00:38:22 UTC 2009


details:	http://hg.adium.im/adium/rev/03c251eb0963
revision:	2104:03c251eb0963
author:		David Smith <catfish.man at gmail.com>
date:		Wed May 06 17:38:16 2009 -0700

Fast enumerate, etc...

diffstat:

 Frameworks/Adium Framework/Source/AIAddressBookController.m  |  11 +++--------
 Frameworks/Adium Framework/Source/AISoundSet.m               |  14 ++++----------
 Plugins/Purple Service/AMPurpleJabberAdHocServer.m           |   4 +---
 Plugins/Purple Service/AMPurpleJabberFormGenerator.m         |   4 +---
 Plugins/Purple Service/ESPurpleJabberAccount.m               |   8 ++------
 Plugins/Purple Service/ESPurpleJabberAccountViewController.m |  12 ++++--------
 Plugins/Purple Service/adiumPurpleCertificateTrustWarning.m  |   6 +-----
 Source/AIContactInfoWindowController.m                       |   5 +----
 Source/GBFireImporter.m                                      |   5 +----
 Source/XtrasInstaller.m                                      |   6 ++----
 10 files changed, 20 insertions(+), 55 deletions(-)

diffs (212 lines):

diff -r 89a96983d1b7 -r 03c251eb0963 Frameworks/Adium Framework/Source/AIAddressBookController.m
--- a/Frameworks/Adium Framework/Source/AIAddressBookController.m	Wed May 06 17:21:36 2009 -0700
+++ b/Frameworks/Adium Framework/Source/AIAddressBookController.m	Wed May 06 17:38:16 2009 -0700
@@ -1280,14 +1280,9 @@
 			[person setValue:[contact phoneticName] forKey:kABFirstNamePhoneticProperty];
 
 		NSString				*UID = contact.formattedUID;
-	
-		NSEnumerator * containedContactEnu = [contact isKindOfClass:[AIMetaContact class]] ? [[(AIMetaContact *)contact uniqueContainedObjects] objectEnumerator] : [[NSArray arrayWithObject:contact] objectEnumerator];
-		AIListObject *c;
-		ABMutableMultiValue		*multiValue;
-		
-		while((c = [containedContactEnu nextObject]))
-		{
-			multiValue = [[ABMutableMultiValue alloc] init];
+			
+		for (AIListObject *c in [contact isKindOfClass:[AIMetaContact class]] ? [(AIMetaContact *)contact uniqueContainedObjects] : [NSArray arrayWithObject:contact])	{
+			ABMutableMultiValue *multiValue = [[ABMutableMultiValue alloc] init];
 			UID = c.formattedUID;
 			serviceProperty = [AIAddressBookController propertyFromService:c.service];
 			
diff -r 89a96983d1b7 -r 03c251eb0963 Frameworks/Adium Framework/Source/AISoundSet.m
--- a/Frameworks/Adium Framework/Source/AISoundSet.m	Wed May 06 17:21:36 2009 -0700
+++ b/Frameworks/Adium Framework/Source/AISoundSet.m	Wed May 06 17:38:16 2009 -0700
@@ -145,27 +145,21 @@
 		NSDictionary 	*soundSet = [NSDictionary dictionaryWithContentsOfFile:soundPlistPath];	
 		int				version = [[soundSet objectForKey:SOUNDSET_VERSION] intValue];
 		
-		if (version == 1) {
-			NSEnumerator	*enumerator;
-			NSString		*key;
-			NSArray			*locations;
-			NSDictionary	*localSounds;
-			
+		if (version == 1) {			
 			//Retrieve the set name and information
 			if(!name) //this will have been set from info.plist if it's a new-format xtra
 				name = [[[inPath lastPathComponent] stringByDeletingPathExtension] retain];
 			info = [[soundSet objectForKey:SOUNDSET_INFO] retain];
 			
 			//Search locations.  If none are provided, search within the soundset folder.
-			locations = [soundSet objectForKey:SOUNDSET_SOUND_LOCATIONS];
+			NSArray *locations = [soundSet objectForKey:SOUNDSET_SOUND_LOCATIONS];
 			if(!locations) locations = [NSArray arrayWithObject:inPath];
 			
 			//Retrieve the sound keys and paths, converting local paths to full paths
-			localSounds = [soundSet objectForKey:SOUNDSET_SOUNDS];
+			NSDictionary *localSounds = [soundSet objectForKey:SOUNDSET_SOUNDS];
 			sounds = [[NSMutableDictionary alloc] init];
 			
-			enumerator = [localSounds keyEnumerator];
-			while((key = [enumerator nextObject])){
+			for (NSString *key in [localSounds keyEnumerator]) {
 				[(NSMutableDictionary *)sounds setObject:[[self _fullPathForSoundAtLocalPath:[localSounds objectForKey:key]
 													  searchLocations:locations] stringByCollapsingBundlePath]
 						   forKey:key];
diff -r 89a96983d1b7 -r 03c251eb0963 Plugins/Purple Service/AMPurpleJabberAdHocServer.m
--- a/Plugins/Purple Service/AMPurpleJabberAdHocServer.m	Wed May 06 17:21:36 2009 -0700
+++ b/Plugins/Purple Service/AMPurpleJabberAdHocServer.m	Wed May 06 17:38:16 2009 -0700
@@ -111,12 +111,10 @@
 }
 
 - (void)addCommandsToXML:(xmlnode*)xml {
-	NSEnumerator *e = [commands keyEnumerator];
-	NSString *node;
 	JabberStream *js = purple_account_get_connection([self.account purpleAccount])->proto_data;
 	char *jid = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, js->user->resource);
 	
-	while((node = [e nextObject])) {
+	for (NSString *node in commands) {
 		xmlnode *item = xmlnode_new_child(xml, "item");
 		xmlnode_set_attrib(item,"jid",jid);
 		xmlnode_set_attrib(item,"name",[[[commands objectForKey:node] objectForKey:@"name"] UTF8String]);
diff -r 89a96983d1b7 -r 03c251eb0963 Plugins/Purple Service/AMPurpleJabberFormGenerator.m
--- a/Plugins/Purple Service/AMPurpleJabberFormGenerator.m	Wed May 06 17:21:36 2009 -0700
+++ b/Plugins/Purple Service/AMPurpleJabberFormGenerator.m	Wed May 06 17:38:16 2009 -0700
@@ -546,9 +546,7 @@
 	
 	xmlnode_set_attrib(result,"type","text-multi");
 	if(value) {
-		NSEnumerator *e = [[value componentsSeparatedByString:@"\n"] objectEnumerator];
-		NSString *line;
-		while((line = [e nextObject]))
+		for (NSString *line in [value componentsSeparatedByString:@"\n"])
 			xmlnode_insert_data(xmlnode_new_child(result,"value"),[line UTF8String],-1);
 	}
 	
diff -r 89a96983d1b7 -r 03c251eb0963 Plugins/Purple Service/ESPurpleJabberAccount.m
--- a/Plugins/Purple Service/ESPurpleJabberAccount.m	Wed May 06 17:21:36 2009 -0700
+++ b/Plugins/Purple Service/ESPurpleJabberAccount.m	Wed May 06 17:38:16 2009 -0700
@@ -820,9 +820,7 @@
 			NSMenu *submenu = [[NSMenu alloc] initWithTitle:gateway.UID];
 			
 			NSArray *menuitemarray = [self menuItemsForContact:gateway];
-			NSEnumerator *e2 = [menuitemarray objectEnumerator];
-			NSMenuItem *m2item;
-			while((m2item = [e2 nextObject]))
+			for (NSMenuItem *m2item in menuitemarray)
 				[submenu addItem:m2item];
 			
 			if([submenu numberOfItems] > 0)
@@ -893,9 +891,7 @@
 		NSString *jid = gateway.UID;
 		NSString *pattern = [@"@" stringByAppendingString:jid];
 		NSMutableArray *gatewayContacts = [[NSMutableArray alloc] init];
-		NSEnumerator *e = [[self contacts] objectEnumerator];
-		AIListContact *contact;
-		while((contact = [e nextObject])) {
+		for (AIListContact *contact in self.contacts) {
 			if([contact.UID hasSuffix:pattern])
 				[gatewayContacts addObject:contact];
 		}
diff -r 89a96983d1b7 -r 03c251eb0963 Plugins/Purple Service/ESPurpleJabberAccountViewController.m
--- a/Plugins/Purple Service/ESPurpleJabberAccountViewController.m	Wed May 06 17:21:36 2009 -0700
+++ b/Plugins/Purple Service/ESPurpleJabberAccountViewController.m	Wed May 06 17:38:16 2009 -0700
@@ -215,20 +215,16 @@
 								   otherButton:nil
 					 informativeTextWithFormat:[NSString stringWithFormat:
 												AILocalizedString(@"Unable to parse the server list at %@. Please try again later.",nil), SERVERFEEDRSSURL]] runModal];
-			} else {
-				float longitude, latitude;
-				
+			} else {				
 				MachineLocation loc;
 				ReadLocation(&loc);
 				
-				latitude = FractToFloat(loc.latitude)*(M_PI/2.0f);
-				longitude = FractToFloat(loc.longitude)*(M_PI/2.0f);
+				float latitude = FractToFloat(loc.latitude)*(M_PI/2.0f);
+				float longitude = FractToFloat(loc.longitude)*(M_PI/2.0f);
 				
 				servers = [[NSMutableArray alloc] init];
-				NSEnumerator *enumer = [items objectEnumerator];
-				NSXMLElement *item;
 				
-				while((item = [enumer nextObject])) {
+				for (NSXMLElement *item in items) {
 					NSXMLElement *title = [[item elementsForName:@"name"] lastObject];
 					if(!title)
 						continue;
diff -r 89a96983d1b7 -r 03c251eb0963 Plugins/Purple Service/adiumPurpleCertificateTrustWarning.m
--- a/Plugins/Purple Service/adiumPurpleCertificateTrustWarning.m	Wed May 06 17:21:36 2009 -0700
+++ b/Plugins/Purple Service/adiumPurpleCertificateTrustWarning.m	Wed May 06 17:38:16 2009 -0700
@@ -15,12 +15,8 @@
 #import "ESPurpleJabberAccount.h"
 
 void adium_query_cert_chain(PurpleSslConnection *gsc, const char *hostname, CFArrayRef certs, void (*query_cert_cb)(gboolean trusted, void *userdata), void *userdata) {
-	NSObject<AIAccountController> *accountController = adium.accountController;
 	// only the jabber service supports this right now
-	NSEnumerator *e = [[accountController accountsCompatibleWithService:[accountController firstServiceWithServiceID:@"Jabber"]] objectEnumerator];
-	ESPurpleJabberAccount *account;
-	
-	while((account = [e nextObject])) {
+	for (ESPurpleJabberAccount *account in [adium.accountController accountsCompatibleWithService:[adium.accountController firstServiceWithServiceID:@"Jabber"]]) {
 		if([account secureConnection] == gsc) {
 			if([account shouldVerifyCertificates])
 				[AIPurpleCertificateTrustWarningAlert displayTrustWarningAlertWithAccount:account
diff -r 89a96983d1b7 -r 03c251eb0963 Source/AIContactInfoWindowController.m
--- a/Source/AIContactInfoWindowController.m	Wed May 06 17:21:36 2009 -0700
+++ b/Source/AIContactInfoWindowController.m	Wed May 06 17:38:16 2009 -0700
@@ -298,10 +298,7 @@
 	}
 	
 	//Configure each pane for this contact.
-	id<AIContentInspectorPane> pane = nil;
-	NSEnumerator *paneEnumerator = [loadedContent objectEnumerator];
-	
-	while((pane = [paneEnumerator nextObject])) {
+	for (id<AIContentInspectorPane> pane in loadedContent) {
 		[pane updateForListObject:displayedObject];
 	}
 }
diff -r 89a96983d1b7 -r 03c251eb0963 Source/GBFireImporter.m
--- a/Source/GBFireImporter.m	Wed May 06 17:21:36 2009 -0700
+++ b/Source/GBFireImporter.m	Wed May 06 17:38:16 2009 -0700
@@ -537,10 +537,7 @@
 		if(![serviceName length])
 			continue;
 		
-		NSEnumerator *accountEnum = [[accountsDict objectForKey:serviceName] objectEnumerator];
-		NSDictionary *account = nil;
-		
-		while((account = [accountEnum nextObject]) != nil)
+		for (NSDictionary *account in [accountsDict objectForKey:serviceName])
 		{
 			NSString *accountName = [account objectForKey:@"userName"];
 			if(![accountName length])
diff -r 89a96983d1b7 -r 03c251eb0963 Source/XtrasInstaller.m
--- a/Source/XtrasInstaller.m	Wed May 06 17:21:36 2009 -0700
+++ b/Source/XtrasInstaller.m	Wed May 06 17:38:16 2009 -0700
@@ -261,11 +261,9 @@
 	fileEnumerator = [fileManager enumeratorAtPath:dest];
 
 	if (decompressionSuccess && fileEnumerator) {
-		NSString		*xtraPath;
-		NSString		*nextFile;
 		NSSet			*supportedDocumentExtensions = [[NSBundle mainBundle] supportedDocumentExtensions];
 
-		while((nextFile = [fileEnumerator nextObject])) {
+		for (NSString *nextFile in fileEnumerator) {
 			/* Ignore hidden files and the __MACOSX folder which some compression engines stick into the archive but
 			 * /usr/bin/unzip doesn't handle properly.
 			 */
@@ -284,7 +282,7 @@
 				}
 
 				if (isSupported) {
-					xtraPath = [dest stringByAppendingPathComponent:nextFile];
+					NSString *xtraPath = [dest stringByAppendingPathComponent:nextFile];
 
 					//Open the file directly
 					AILogWithSignature(@"Installing %@",xtraPath);




More information about the commits mailing list