diff --git a/ChangeLog b/ChangeLog index 8ec07fad8..86d1b9f53 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-04-25 Richard Frith-Macdonald + + * Source/NSPropertyList.m: + Use more memory efficient bitmaps for old style property list parsing + where we know we are only using 8bit characters. + 2008-03-20 David Chisnall 0) -static unsigned const char *hexdigitsBitmapRep = NULL; -#define GS_IS_HEXDIGIT(X) IS_BIT_SET(hexdigitsBitmapRep[(X)/8], (X) % 8) +#define GS_IS_QUOTABLE(X) IS_BIT_SET(quotables[(X)/8], (X) % 8) -static void setupHexdigits(void) -{ - if (hexdigitsBitmapRep == NULL) - { - NSCharacterSet *hexdigits; - NSData *bitmap; +#define GS_IS_WHITESPACE(X) IS_BIT_SET(whitespace[(X)/8], (X) % 8) - hexdigits = [NSCharacterSet characterSetWithCharactersInString: - @"0123456789abcdefABCDEF"]; - bitmap = RETAIN([hexdigits bitmapRepresentation]); - hexdigitsBitmapRep = [bitmap bytes]; - } -} - -static NSCharacterSet *quotables = nil; static NSCharacterSet *oldQuotables = nil; static NSCharacterSet *xmlQuotables = nil; -static unsigned const char *quotablesBitmapRep = NULL; -#define GS_IS_QUOTABLE(X) IS_BIT_SET(quotablesBitmapRep[(X)/8], (X) % 8) - static void setupQuotables(void) { - if (quotablesBitmapRep == NULL) + if (oldQuotables == nil) { NSMutableCharacterSet *s; - NSData *bitmap; - s = [[NSCharacterSet characterSetWithCharactersInString: - @"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - @"abcdefghijklmnopqrstuvwxyz!#$%&*+-./:?@|~_^"] - mutableCopy]; - [s invert]; - quotables = [s copy]; - RELEASE(s); - bitmap = RETAIN([quotables bitmapRepresentation]); - quotablesBitmapRep = [bitmap bytes]; s = [[NSCharacterSet characterSetWithCharactersInString: @"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" @"abcdefghijklmnopqrstuvwxyz$./_"] @@ -466,29 +516,6 @@ static void setupQuotables(void) } } -static unsigned const char *whitespaceBitmapRep = NULL; -#define GS_IS_WHITESPACE(X) IS_BIT_SET(whitespaceBitmapRep[(X)/8], (X) % 8) - -static void setupWhitespace(void) -{ - if (whitespaceBitmapRep == NULL) - { - NSCharacterSet *whitespace; - NSData *bitmap; - -/* - We can not use whitespaceAndNewlineCharacterSet here as this would lead - to a recursion, as this also reads in a property list. - whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet]; -*/ - whitespace = [NSCharacterSet characterSetWithCharactersInString: - @" \t\r\n\f\b"]; - - bitmap = RETAIN([whitespace bitmapRepresentation]); - whitespaceBitmapRep = [bitmap bytes]; - } -} - #ifdef HAVE_LIBXML #import "GNUstepBase/GSXML.h" static int XML_ELEMENT_NODE; @@ -620,7 +647,7 @@ static inline id parseQuotedString(pldata* pld) } else if (escaped > 1) { - if (hex && GS_IS_HEXDIGIT(c)) + if (hex && isxdigit(c)) { shrink++; escaped++; @@ -714,7 +741,7 @@ static inline id parseQuotedString(pldata* pld) } else if (escaped > 1) { - if (hex && GS_IS_HEXDIGIT(c)) + if (hex && isxdigit(c)) { chars[k] <<= 4; chars[k] |= char2num(c); @@ -1089,8 +1116,8 @@ static id parsePlItem(pldata* pld) data = [[NSMutableData alloc] initWithCapacity: 0]; skipSpace(pld); while (pld->pos < max - && GS_IS_HEXDIGIT(pld->ptr[pld->pos]) - && GS_IS_HEXDIGIT(pld->ptr[pld->pos+1])) + && isxdigit(pld->ptr[pld->pos]) + && isxdigit(pld->ptr[pld->pos+1])) { unsigned char byte; @@ -2401,10 +2428,7 @@ static BOOL classInitialized = NO; plSet = (id (*)(id, SEL, id, id)) [plDictionary instanceMethodForSelector: @selector(setObject:forKey:)]; - setupHexdigits(); setupQuotables(); - setupWhitespace(); - } }