Revision: 12206
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=12206&view=rev
Author:   amaxwell
Date:     2008-01-02 13:39:46 -0800 (Wed, 02 Jan 2008)

Log Message:
-----------
eliminate @synchronized since the local file set isn't accessed from a 
secondary thread anymore

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

Modified: trunk/bibdesk/BDSKTypeManager.m
===================================================================
--- trunk/bibdesk/BDSKTypeManager.m     2008-01-02 20:48:13 UTC (rev 12205)
+++ trunk/bibdesk/BDSKTypeManager.m     2008-01-02 21:39:46 UTC (rev 12206)
@@ -52,7 +52,6 @@
 + (void)initialize
 {
     OBINITIALIZE;
-    // Create the singleton here since +initialize is thread safe; 
@synchronized in +sharedManager was killing performance, especially with the 
NSString category methods.
     if(sharedInstance == nil) 
         sharedInstance = [[self alloc] init];
 }
@@ -184,42 +183,40 @@
 }
 
 - (void)reloadTypeInfo{
-       @synchronized(self){
-        // Load the TypeInfo plists
-        NSDictionary *typeInfoDict = [NSDictionary 
dictionaryWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] 
stringByAppendingPathComponent:TYPE_INFO_FILENAME]];
+    // Load the TypeInfo plists
+    NSDictionary *typeInfoDict = [NSDictionary 
dictionaryWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] 
stringByAppendingPathComponent:TYPE_INFO_FILENAME]];
 
-        NSFileManager *fm = [NSFileManager defaultManager];
-        NSString *userTypeInfoPath = [[fm 
currentApplicationSupportPathForCurrentUser] 
stringByAppendingPathComponent:TYPE_INFO_FILENAME];
-        NSDictionary *userTypeInfoDict;
-        
-        if ([fm fileExistsAtPath:userTypeInfoPath]) {
-            userTypeInfoDict = [NSDictionary 
dictionaryWithContentsOfFile:userTypeInfoPath];
-            // set all the lists we support in the user file
-            [self setFieldsForTypesDict:[userTypeInfoDict 
objectForKey:FIELDS_FOR_TYPES_KEY]];
-            [self setTypesForFileTypeDict:[NSDictionary 
dictionaryWithObjectsAndKeys: 
-                [[userTypeInfoDict objectForKey:TYPES_FOR_FILE_TYPE_KEY] 
objectForKey:BDSKBibtexString], BDSKBibtexString, 
-                [[typeInfoDict objectForKey:TYPES_FOR_FILE_TYPE_KEY] 
objectForKey:@"PubMed"], @"PubMed", nil]];
-        } else {
-            [self setFieldsForTypesDict:[typeInfoDict 
objectForKey:FIELDS_FOR_TYPES_KEY]];
-            [self setTypesForFileTypeDict:[typeInfoDict 
objectForKey:TYPES_FOR_FILE_TYPE_KEY]];
-        }
-
-        [self setFileTypesDict:[typeInfoDict objectForKey:FILE_TYPES_KEY]];
-        [self setFieldNameForPubMedTagDict:[typeInfoDict 
objectForKey:BIBTEX_FIELDS_FOR_PUBMED_TAGS_KEY]];
-        [self setBibtexTypeForPubMedTypeDict:[typeInfoDict 
objectForKey:BIBTEX_TYPES_FOR_PUBMED_TYPES_KEY]];
-        [self setFieldNamesForMARCTagDict:[typeInfoDict 
objectForKey:BIBTEX_FIELDS_FOR_MARC_TAGS_KEY]];
-        [self setMODSGenresForBibTeXTypeDict:[typeInfoDict 
objectForKey:MODS_GENRES_FOR_BIBTEX_TYPES_KEY]];
-        [self setFieldNameForJSTORTagDict:[typeInfoDict 
objectForKey:BIBTEX_FIELDS_FOR_JSTOR_TAGS_KEY]];
-        [self setFieldDescriptionForJSTORTagDict:[typeInfoDict 
objectForKey:FIELD_DESCRIPTIONS_FOR_JSTOR_TAGS_KEY]];
-        [self setFieldNameForWebOfScienceTagDict:[typeInfoDict 
objectForKey:BIBTEX_FIELDS_FOR_WOS_TAGS_KEY]];
-        [self setFieldDescriptionForWebOfScienceTagDict:[typeInfoDict 
objectForKey:FIELD_DESCRIPTIONS_FOR_WOS_TAGS_KEY]];
-        [self setBibtexTypeForWebOfScienceTypeDict:[typeInfoDict 
objectForKey:BIBTEX_TYPES_FOR_WOS_TYPES_KEY]];
-        [self setBibtexTypeForDublinCoreTypeDict:[typeInfoDict 
objectForKey:BIBTEX_TYPES_FOR_DC_TYPES_KEY]];        
-        [self setFieldNameForDublinCoreTermDict:[typeInfoDict 
objectForKey:BIBTEX_FIELDS_FOR_DC_TERMS_KEY]];
-        [self setFieldNameForReferTagDict:[typeInfoDict 
objectForKey:BIBTEX_FIELDS_FOR_REFER_TAGS_KEY]];
-        [self setBibtexTypeForReferTypeDict:[typeInfoDict 
objectForKey:BIBTEX_TYPES_FOR_REFER_TYPES_KEY]];
-        [self setBibtexTypeForHCiteTypeDict:[typeInfoDict 
objectForKey:BIBTEX_TYPES_FOR_HCITE_TYPES_KEY]];
+    NSFileManager *fm = [NSFileManager defaultManager];
+    NSString *userTypeInfoPath = [[fm 
currentApplicationSupportPathForCurrentUser] 
stringByAppendingPathComponent:TYPE_INFO_FILENAME];
+    NSDictionary *userTypeInfoDict;
+    
+    if ([fm fileExistsAtPath:userTypeInfoPath]) {
+        userTypeInfoDict = [NSDictionary 
dictionaryWithContentsOfFile:userTypeInfoPath];
+        // set all the lists we support in the user file
+        [self setFieldsForTypesDict:[userTypeInfoDict 
objectForKey:FIELDS_FOR_TYPES_KEY]];
+        [self setTypesForFileTypeDict:[NSDictionary 
dictionaryWithObjectsAndKeys: 
+            [[userTypeInfoDict objectForKey:TYPES_FOR_FILE_TYPE_KEY] 
objectForKey:BDSKBibtexString], BDSKBibtexString, 
+            [[typeInfoDict objectForKey:TYPES_FOR_FILE_TYPE_KEY] 
objectForKey:@"PubMed"], @"PubMed", nil]];
+    } else {
+        [self setFieldsForTypesDict:[typeInfoDict 
objectForKey:FIELDS_FOR_TYPES_KEY]];
+        [self setTypesForFileTypeDict:[typeInfoDict 
objectForKey:TYPES_FOR_FILE_TYPE_KEY]];
     }
+
+    [self setFileTypesDict:[typeInfoDict objectForKey:FILE_TYPES_KEY]];
+    [self setFieldNameForPubMedTagDict:[typeInfoDict 
objectForKey:BIBTEX_FIELDS_FOR_PUBMED_TAGS_KEY]];
+    [self setBibtexTypeForPubMedTypeDict:[typeInfoDict 
objectForKey:BIBTEX_TYPES_FOR_PUBMED_TYPES_KEY]];
+    [self setFieldNamesForMARCTagDict:[typeInfoDict 
objectForKey:BIBTEX_FIELDS_FOR_MARC_TAGS_KEY]];
+    [self setMODSGenresForBibTeXTypeDict:[typeInfoDict 
objectForKey:MODS_GENRES_FOR_BIBTEX_TYPES_KEY]];
+    [self setFieldNameForJSTORTagDict:[typeInfoDict 
objectForKey:BIBTEX_FIELDS_FOR_JSTOR_TAGS_KEY]];
+    [self setFieldDescriptionForJSTORTagDict:[typeInfoDict 
objectForKey:FIELD_DESCRIPTIONS_FOR_JSTOR_TAGS_KEY]];
+    [self setFieldNameForWebOfScienceTagDict:[typeInfoDict 
objectForKey:BIBTEX_FIELDS_FOR_WOS_TAGS_KEY]];
+    [self setFieldDescriptionForWebOfScienceTagDict:[typeInfoDict 
objectForKey:FIELD_DESCRIPTIONS_FOR_WOS_TAGS_KEY]];
+    [self setBibtexTypeForWebOfScienceTypeDict:[typeInfoDict 
objectForKey:BIBTEX_TYPES_FOR_WOS_TYPES_KEY]];
+    [self setBibtexTypeForDublinCoreTypeDict:[typeInfoDict 
objectForKey:BIBTEX_TYPES_FOR_DC_TYPES_KEY]];        
+    [self setFieldNameForDublinCoreTermDict:[typeInfoDict 
objectForKey:BIBTEX_FIELDS_FOR_DC_TERMS_KEY]];
+    [self setFieldNameForReferTagDict:[typeInfoDict 
objectForKey:BIBTEX_FIELDS_FOR_REFER_TAGS_KEY]];
+    [self setBibtexTypeForReferTypeDict:[typeInfoDict 
objectForKey:BIBTEX_TYPES_FOR_REFER_TYPES_KEY]];
+    [self setBibtexTypeForHCiteTypeDict:[typeInfoDict 
objectForKey:BIBTEX_TYPES_FOR_HCITE_TYPES_KEY]];
        
        [self reloadAllFieldNames];
        
@@ -229,57 +226,51 @@
 }
 
 - (void)reloadAllFieldNames {
-    @synchronized(self){
-        NSMutableSet *allFields = [NSMutableSet setWithCapacity:30];
-        NSEnumerator *typeEnum = [[self bibTypesForFileType:BDSKBibtexString] 
objectEnumerator];
-        NSString *type;
-        
-        while (type = [typeEnum nextObject]) {
-            [allFields addObjectsFromArray:[[fieldsForTypesDict 
objectForKey:type] objectForKey:REQUIRED_KEY]];
-            [allFields addObjectsFromArray:[[fieldsForTypesDict 
objectForKey:type] objectForKey:OPTIONAL_KEY]];
-        }
-        OFPreferenceWrapper *pw = [OFPreferenceWrapper 
sharedPreferenceWrapper];
-        [allFields addObjectsFromArray:[pw 
stringArrayForKey:BDSKDefaultFieldsKey]];
-        [allFields addObjectsFromArray:[pw 
stringArrayForKey:BDSKLocalFileFieldsKey]];
-        [allFields addObjectsFromArray:[pw 
stringArrayForKey:BDSKRemoteURLFieldsKey]];
-        [allFields addObjectsFromArray:[pw 
stringArrayForKey:BDSKBooleanFieldsKey]];
-        [allFields addObjectsFromArray:[pw 
stringArrayForKey:BDSKRatingFieldsKey]];
-        [allFields addObjectsFromArray:[pw 
stringArrayForKey:BDSKTriStateFieldsKey]];
-        [allFields addObjectsFromArray:[pw 
stringArrayForKey:BDSKCitationFieldsKey]];
-        [allFields addObjectsFromArray:[pw 
stringArrayForKey:BDSKPersonFieldsKey]];
-        
-        [self setAllFieldNames:allFields];
+    NSMutableSet *allFields = [NSMutableSet setWithCapacity:30];
+    NSEnumerator *typeEnum = [[self bibTypesForFileType:BDSKBibtexString] 
objectEnumerator];
+    NSString *type;
+    
+    while (type = [typeEnum nextObject]) {
+        [allFields addObjectsFromArray:[[fieldsForTypesDict objectForKey:type] 
objectForKey:REQUIRED_KEY]];
+        [allFields addObjectsFromArray:[[fieldsForTypesDict objectForKey:type] 
objectForKey:OPTIONAL_KEY]];
     }
+    OFPreferenceWrapper *pw = [OFPreferenceWrapper sharedPreferenceWrapper];
+    [allFields addObjectsFromArray:[pw 
stringArrayForKey:BDSKDefaultFieldsKey]];
+    [allFields addObjectsFromArray:[pw 
stringArrayForKey:BDSKLocalFileFieldsKey]];
+    [allFields addObjectsFromArray:[pw 
stringArrayForKey:BDSKRemoteURLFieldsKey]];
+    [allFields addObjectsFromArray:[pw 
stringArrayForKey:BDSKBooleanFieldsKey]];
+    [allFields addObjectsFromArray:[pw stringArrayForKey:BDSKRatingFieldsKey]];
+    [allFields addObjectsFromArray:[pw 
stringArrayForKey:BDSKTriStateFieldsKey]];
+    [allFields addObjectsFromArray:[pw 
stringArrayForKey:BDSKCitationFieldsKey]];
+    [allFields addObjectsFromArray:[pw stringArrayForKey:BDSKPersonFieldsKey]];
     
+    [self setAllFieldNames:allFields];
+
 }
 
 - (void)reloadURLFields {
-    @synchronized(self){
-        [localFileFieldsSet removeAllObjects];
-        [remoteURLFieldsSet removeAllObjects];
-        [allURLFieldsSet removeAllObjects];
-        
-        [localFileFieldsSet addObjectsFromArray:[[OFPreferenceWrapper 
sharedPreferenceWrapper] stringArrayForKey:BDSKLocalFileFieldsKey]];
-        [remoteURLFieldsSet addObjectsFromArray:[[OFPreferenceWrapper 
sharedPreferenceWrapper] stringArrayForKey:BDSKRemoteURLFieldsKey]];
-        [allURLFieldsSet unionSet:remoteURLFieldsSet];
-        [allURLFieldsSet unionSet:localFileFieldsSet];
-    }
+    [localFileFieldsSet removeAllObjects];
+    [remoteURLFieldsSet removeAllObjects];
+    [allURLFieldsSet removeAllObjects];
+    
+    [localFileFieldsSet addObjectsFromArray:[[OFPreferenceWrapper 
sharedPreferenceWrapper] stringArrayForKey:BDSKLocalFileFieldsKey]];
+    [remoteURLFieldsSet addObjectsFromArray:[[OFPreferenceWrapper 
sharedPreferenceWrapper] stringArrayForKey:BDSKRemoteURLFieldsKey]];
+    [allURLFieldsSet unionSet:remoteURLFieldsSet];
+    [allURLFieldsSet unionSet:localFileFieldsSet];
 }
 
 - (void)reloadSpecialFields{
-    @synchronized(self){
-        [ratingFieldsSet removeAllObjects];
-        [triStateFieldsSet removeAllObjects];
-        [booleanFieldsSet removeAllObjects];
-        [citationFieldsSet removeAllObjects];
-        [personFieldsSet removeAllObjects];
-        
-        [ratingFieldsSet addObjectsFromArray:[[OFPreferenceWrapper 
sharedPreferenceWrapper] stringArrayForKey:BDSKRatingFieldsKey]];
-        [triStateFieldsSet addObjectsFromArray:[[OFPreferenceWrapper 
sharedPreferenceWrapper] stringArrayForKey:BDSKTriStateFieldsKey]];
-        [booleanFieldsSet addObjectsFromArray:[[OFPreferenceWrapper 
sharedPreferenceWrapper] stringArrayForKey:BDSKBooleanFieldsKey]];    
-        [citationFieldsSet addObjectsFromArray:[[OFPreferenceWrapper 
sharedPreferenceWrapper] stringArrayForKey:BDSKCitationFieldsKey]];   
-        [personFieldsSet addObjectsFromArray:[[OFPreferenceWrapper 
sharedPreferenceWrapper] stringArrayForKey:BDSKPersonFieldsKey]];
-    }
+    [ratingFieldsSet removeAllObjects];
+    [triStateFieldsSet removeAllObjects];
+    [booleanFieldsSet removeAllObjects];
+    [citationFieldsSet removeAllObjects];
+    [personFieldsSet removeAllObjects];
+    
+    [ratingFieldsSet addObjectsFromArray:[[OFPreferenceWrapper 
sharedPreferenceWrapper] stringArrayForKey:BDSKRatingFieldsKey]];
+    [triStateFieldsSet addObjectsFromArray:[[OFPreferenceWrapper 
sharedPreferenceWrapper] stringArrayForKey:BDSKTriStateFieldsKey]];
+    [booleanFieldsSet addObjectsFromArray:[[OFPreferenceWrapper 
sharedPreferenceWrapper] stringArrayForKey:BDSKBooleanFieldsKey]];    
+    [citationFieldsSet addObjectsFromArray:[[OFPreferenceWrapper 
sharedPreferenceWrapper] stringArrayForKey:BDSKCitationFieldsKey]];   
+    [personFieldsSet addObjectsFromArray:[[OFPreferenceWrapper 
sharedPreferenceWrapper] stringArrayForKey:BDSKPersonFieldsKey]];
 }
 
 - (void)reloadGroupFields{
@@ -630,13 +621,8 @@
     return allURLFieldsSet;
 }
 
-// this one needs to be thread safe
 - (NSSet *)localFileFieldsSet{
-    NSSet *set;
-    @synchronized(self){
-        set = [[localFileFieldsSet copy] autorelease];
-    }
-    return set;
+    return localFileFieldsSet;
 }
 
 - (NSSet *)remoteURLFieldsSet{


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

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to