mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
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
This commit is contained in:
parent
a81cdb7a1e
commit
e3dd69dab2
1 changed files with 19 additions and 11 deletions
|
@ -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];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue