From 4680675cd26ee47799edce65dd7457087c69dc92 Mon Sep 17 00:00:00 2001 From: Nicola Pero Date: Fri, 6 Apr 2001 22:51:48 +0000 Subject: [PATCH] Optimization by inlining function to evaluate if char is a path separator git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@9534 72102866-910b-0410-8b05-ffd578937521 --- Source/NSString.m | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/Source/NSString.m b/Source/NSString.m index 19adb72fc..f17e70c0c 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -185,7 +185,6 @@ static NSString *pathSepString = @"/"; static NSString *rootPath = @"/"; #endif -static BOOL (*sepMember)(NSCharacterSet*, SEL, unichar) = 0; static NSCharacterSet *myPathSeps = nil; /* * We can't have a 'pathSeps' variable initialized in the +initialize @@ -202,21 +201,30 @@ pathSeps() myPathSeps = [NSCharacterSet characterSetWithCharactersInString: @"/"]; #endif IF_NO_GC(RETAIN(myPathSeps)); - sepMember = (BOOL (*)(NSCharacterSet*, SEL, unichar)) - [myPathSeps methodForSelector: @selector(characterIsMember:)]; } return myPathSeps; } -static BOOL +inline static BOOL pathSepMember(unichar c) { - if (sepMember == 0) - pathSeps(); - - return (*sepMember)(myPathSeps, @selector(characterIsMember:), c); + +#if defined(__MINGW__) + if (c == (unichar)'\\' || c == (unichar)'/') +#else + if (c == (unichar)'/') +#endif + { + return YES; + } + else + { + return NO; + } } + + /* Convert a high-low surrogate pair into Unicode scalar code-point */ static inline gsu32 surrogatePairValue(unichar high, unichar low) @@ -2926,11 +2934,11 @@ handle_printf_atsign (FILE *stream, { NSMutableArray *a; NSArray *r; - int i; + unsigned i, count = [paths count]; a = [[NSMutableArray allocWithZone: NSDefaultMallocZone()] - initWithCapacity: [paths count]]; - for (i = 0; i < [paths count]; i++) + initWithCapacity: count]; + for (i = 0; i < count; i++) { NSString *s = [paths objectAtIndex: i];