From 2352e05045b15ca96b9f6d343e933c467f756731 Mon Sep 17 00:00:00 2001 From: Richard Frith-MacDonald Date: Sat, 7 Jun 2008 06:00:26 +0000 Subject: [PATCH] Minor optimisation for getting dictionary representation of defaults. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@26604 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 3 ++- Source/NSUserDefaults.m | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) 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() {