From 3e4f05e940e164e950e123f12cab18a563014c25 Mon Sep 17 00:00:00 2001 From: Richard Frith-Macdonald Date: Thu, 7 Jun 2001 06:10:33 +0000 Subject: [PATCH] Shallow copy for attributes git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@10099 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 +++++ Source/GSTextStorage.m | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3af6e3dd5..b536815de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-06-07 Richard Frith-Macdonald + + * Source/GSAttributedString.m: When caching attribute dictionaries + we make an immutable copy of the dictionary with shallow copy. + 2001-06-06 Adam Fedor * Source/NSBox.m ([NSBox -minimumSize]): New method. diff --git a/Source/GSTextStorage.m b/Source/GSTextStorage.m index 5a2318779..3019150a7 100644 --- a/Source/GSTextStorage.m +++ b/Source/GSTextStorage.m @@ -84,7 +84,11 @@ cacheAttributes(NSDictionary *attrs) node = GSIMapNodeForKey(&attrMap, (GSIMapKey)attrs); if (node == 0) { - attrs = [attrs copy]; + /* + * Shallow copy of dictionary, without copying objects ... results + * in an immutable dictionary that can safely be cached. + */ + attrs = [[NSDictionary alloc] initWithDictionary: attrs copyItems: NO]; GSIMapAddPair(&attrMap, (GSIMapKey)attrs, (GSIMapVal)(unsigned)1); } else