adium-1.4 3330:2cb58ee83c27: Patch from an anonymous source impr...

commits at adium.im commits at adium.im
Wed Jan 26 00:59:38 UTC 2011


details:	http://hg.adium.im/adium-1.4/rev/2cb58ee83c27
revision:	3330:2cb58ee83c27
author:		Evan Schoenberg
date:		Tue Jan 25 18:58:45 2011 -0600

Patch from an anonymous source improving performance of date parsing, which in turn provides a 40% speed boost in +[AILoggerPlugin sortedArrayOfLogFilesForChat:]
(transplanted from e820c84b5b9863bcfb53692bd1a79d8f24211f36)

diffs (21 lines):

diff -r b38438052fe1 -r 2cb58ee83c27 Frameworks/AIUtilities Framework/Source/NSCalendarDate+ISO8601Parsing.m
--- a/Frameworks/AIUtilities Framework/Source/NSCalendarDate+ISO8601Parsing.m	Tue Jan 18 22:01:45 2011 +0100
+++ b/Frameworks/AIUtilities Framework/Source/NSCalendarDate+ISO8601Parsing.m	Tue Jan 25 18:58:45 2011 -0600
@@ -565,7 +565,16 @@
 								if(negative) tz_minute = -tz_minute;
 							}
 
-							timeZone = [NSTimeZone timeZoneForSecondsFromGMT:(tz_hour * 3600) + (tz_minute * 60)];
+							NSInteger secondsFromGMT = (tz_hour * 3600) + (tz_minute * 60);
+							static NSInteger lastUsedSecondsFromGMT = NSNotFound;
+							static NSTimeZone *lastUsedTimeZone;
+							if (secondsFromGMT == lastUsedSecondsFromGMT)
+								timeZone = [[lastUsedTimeZone retain] autorelease];
+							else
+								timeZone = [NSTimeZone timeZoneForSecondsFromGMT:secondsFromGMT];
+							lastUsedSecondsFromGMT = secondsFromGMT;
+							[lastUsedTimeZone autorelease];
+							lastUsedTimeZone = [timeZone retain];
 						}
 				}
 			}




More information about the commits mailing list