Fix NSCharacterSet caching bug

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@18017 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2003-11-01 07:30:21 +00:00
parent 310d9bd763
commit a9fc62765c
2 changed files with 11 additions and 3 deletions

View file

@ -5,6 +5,12 @@ Sat Nov 01 07:05:00 2003 Richard Frith-Macdonald <rfm@gnu.org>
not sure what the actual problem was, so this change may have merely
re-hidden a bug :-(
* Source/Additions/Unicode.m: Simplify to use non-recursive lock.
* Source/NSCharacterSet.m
([NSCharacterSet _bitmapForSet:number:]): Restore caching while
retaining the intended behavior of the previous change (is that
intended behavior correct?).
Perhaps should maintain a separate cache for each subclass ...
or should that be the responsibility of the subclass itsself?
2003-10-31 David Ayers <d.ayers@inode.at>

View file

@ -42,6 +42,7 @@ static NSString* NSCharacterSet_PATH = @"NSCharacterSets";
#define MAX_STANDARD_SETS 15
static NSCharacterSet* cache_set[MAX_STANDARD_SETS];
static NSLock* cache_lock = nil;
Class abstract = nil;
@implementation NSCharacterSet
@ -65,6 +66,7 @@ static NSLock* cache_lock = nil;
{
unsigned i;
abstract = [NSCharacterSet class];
for (i = 0; i < MAX_STANDARD_SETS; i++)
{
cache_set[i] = 0;
@ -138,7 +140,6 @@ static NSLock* cache_lock = nil;
{
/* Else cache the set */
cache_set[number] = RETAIN(set);
}
NS_HANDLER
[cache_lock unlock];
@ -151,9 +152,10 @@ static NSLock* cache_lock = nil;
[cache_lock unlock];
if ([self isSubclassOfClass: [NSCharacterSet class]])
if (self != abstract && self != [set class])
{
NSData *data;
NSData *data;
data = [set bitmapRepresentation];
set = [self characterSetWithBitmapRepresentation: data];
}