Revision: 17925
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=17925&view=rev
Author:   hofman
Date:     2011-06-03 00:00:23 +0000 (Fri, 03 Jun 2011)

Log Message:
-----------
cache date formatter for displayValueOfField:, as this is used repeatedly, and 
apparently creating a formatter is relatively slow.

Modified Paths:
--------------
    trunk/bibdesk/BibItem.m

Modified: trunk/bibdesk/BibItem.m
===================================================================
--- trunk/bibdesk/BibItem.m     2011-06-02 21:24:47 UTC (rev 17924)
+++ trunk/bibdesk/BibItem.m     2011-06-03 00:00:23 UTC (rev 17925)
@@ -1351,11 +1351,13 @@
         NSDate *date = [self date];
         if(nil == date) 
             return nil;
-        NSString *format = [NSString isEmptyString:[self 
valueOfField:BDSKMonthString]] ? @"yyyy" : @"MMM yyyy";
-        NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] 
autorelease];
-        [formatter setFormatterBehavior:NSDateFormatterBehavior10_4];
-        [formatter setDateFormat:format];
-        [formatter setLocale:[NSLocale currentLocale]]; // is this necessary?
+        static NSDateFormatter *formatter = nil;
+        if (formatter == nil) {
+            formatter = [[[NSDateFormatter alloc] init] autorelease];
+            [formatter setFormatterBehavior:NSDateFormatterBehavior10_4];
+            [formatter setLocale:[NSLocale currentLocale]]; // is this 
necessary?
+        }
+        [formatter setDateFormat:[NSString isEmptyString:[self 
valueOfField:BDSKMonthString]] ? @"yyyy" : @"MMM yyyy"];
         return [formatter stringFromDate:date];
      }else if([field isEqualToString: BDSKFirstAuthorString] ){
         return [[self authorAtIndex:0] displayName];


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Discover what all the cheering's about.
Get your free trial download today. 
http://p.sf.net/sfu/quest-dev2dev2 
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to