adium 4878:bf3a2a2ee96e: Make sure everything in GetMetadataForF...

commits at adium.im commits at adium.im
Mon Jun 25 00:59:11 UTC 2012


details:	http://hg.adium.im/adium/rev/bf3a2a2ee96e
revision:	4878:bf3a2a2ee96e
branch:		adium-1.5.2
author:		Thijs Alkemade <thijsalkemade at gmail.com>
date:		Mon Jun 25 02:57:36 2012 +0200

Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.

diffs (64 lines):

diff -r ba261521004d -r bf3a2a2ee96e Other/Adium Spotlight Importer/GetMetadataForFile.m
--- a/Other/Adium Spotlight Importer/GetMetadataForFile.m	Mon Jun 25 02:10:25 2012 +0200
+++ b/Other/Adium Spotlight Importer/GetMetadataForFile.m	Mon Jun 25 02:57:36 2012 +0200
@@ -307,11 +307,29 @@
 
 NSString *CopyTextContentForXMLLogData(NSData *data) {
     NSString *contentString = nil;
-    NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] initWithData:data options:NSXMLNodePreserveCDATA error:NULL];
+	NSError *err;
+    NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] initWithData:data options:NSXMLNodePreserveCDATA error:&err];
+	
     if (xmlDoc) {
-        NSArray *contentArray = [xmlDoc nodesForXPath:@"//message//text()" error:NULL];
-		contentString = [contentArray componentsJoinedByString:@" "];
+		NSArray *children = [[xmlDoc rootElement] children];
+		NSMutableArray *messages = [NSMutableArray array];
+		
+		for (NSXMLNode *child in children) {
+			if ([child.name isEqualToString:@"message"]) {
+				[messages addObject:child.stringValue];
+			}
+		}
+		
+		if (messages.count) contentString = [messages componentsJoinedByString:@" "];
+		
         [xmlDoc release];
-    }
+    } else {
+#ifdef AILogWithSignature
+		AILogWithSignature(@"Parsing log failed: %@", err);
+#endif
+	}
+	
+	[contentString retain];
+	
     return contentString;
 }
diff -r ba261521004d -r bf3a2a2ee96e Source/AILoggerPlugin.m
--- a/Source/AILoggerPlugin.m	Mon Jun 25 02:10:25 2012 +0200
+++ b/Source/AILoggerPlugin.m	Mon Jun 25 02:57:36 2012 +0200
@@ -1494,20 +1494,20 @@
 							 *  3. On 10.3, this means that logs' markup is indexed in addition to their text, which is undesireable.
 							 */
 							
-                            NSData *documentData = [CopyDataForURL(NULL, logURL) autorelease];
+                            NSData *documentData = CopyDataForURL(NULL, logURL);
 							
 							dispatch_semaphore_wait(jobSemaphore, DISPATCH_TIME_FOREVER);
                             
 							dispatch_group_async(logIndexingGroup, defaultDispatchQueue, blockWithAutoreleasePool(^{
                                 __block CFStringRef documentText = CopyTextContentForFileData(NULL, logURL, documentData);
 								
-								if (documentText) CFRetain(documentText);
+								[documentData release];
 								
                                 dispatch_group_async(logIndexingGroup, defaultDispatchQueue, blockWithAutoreleasePool(^{
                                     
 									CFRetain(searchIndex);
 									
-                                    if (documentText && bself.indexingAllowed) {
+                                    if (documentText && CFStringGetLength(documentText) > 0 && bself.indexingAllowed) {
 										static dispatch_queue_t skQueue = nil;
 										static dispatch_once_t onceToken;
 										dispatch_once(&onceToken, ^{




More information about the commits mailing list