diff --git a/ChangeLog b/ChangeLog index 81af26bec..8cf17c885 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,8 @@ 2008-06-07 Richard Frith-Macdonald * Source/NSUserDefaults.m: - Fix possible deadlock reported by Larry Campbell + Fix possible deadlock reported by Larry Campbell, and improve + optimisation a little. 2008-06-06 Richard Frith-Macdonald diff --git a/Source/NSUserDefaults.m b/Source/NSUserDefaults.m index d293efeb1..7ddda2726 100644 --- a/Source/NSUserDefaults.m +++ b/Source/NSUserDefaults.m @@ -1705,10 +1705,11 @@ static BOOL isLocked = NO; { if ((dict = (*pImp)(_persDomains, objectForKeySel, obj)) != nil || (dict = (*tImp)(_tempDomains, objectForKeySel, obj)) != nil) - (*addImp)(dictRep, addSel, dict); + { + (*addImp)(dictRep, addSel, dict); + } } - _dictionaryRep = [dictRep copy]; - RELEASE(dictRep); + _dictionaryRep = [dictRep makeImmutableCopyOnFail: NO]; } rep = RETAIN(_dictionaryRep); [_lock unlock]; @@ -1872,9 +1873,11 @@ GSPrivateDefaultsFlag(GSUserDefaultFlagType type) return flags[type]; } -/* FIXME ... Slightly faster than +/* Slightly faster than * [[NSUserDefaults standardUserDefaults] dictionaryRepresentation] - * but is it really worthwile? + * Avoiding the autorelease of the standard defaults turns out to be + * a modest but significant gain when making heavy use of methods which + * need localisation. */ NSDictionary *GSPrivateDefaultLocale() {