mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +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
1e28431cac
commit
4680675cd2
1 changed files with 19 additions and 11 deletions
|
@ -185,7 +185,6 @@ static NSString *pathSepString = @"/";
|
||||||
static NSString *rootPath = @"/";
|
static NSString *rootPath = @"/";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static BOOL (*sepMember)(NSCharacterSet*, SEL, unichar) = 0;
|
|
||||||
static NSCharacterSet *myPathSeps = nil;
|
static NSCharacterSet *myPathSeps = nil;
|
||||||
/*
|
/*
|
||||||
* We can't have a 'pathSeps' variable initialized in the +initialize
|
* We can't have a 'pathSeps' variable initialized in the +initialize
|
||||||
|
@ -202,21 +201,30 @@ pathSeps()
|
||||||
myPathSeps = [NSCharacterSet characterSetWithCharactersInString: @"/"];
|
myPathSeps = [NSCharacterSet characterSetWithCharactersInString: @"/"];
|
||||||
#endif
|
#endif
|
||||||
IF_NO_GC(RETAIN(myPathSeps));
|
IF_NO_GC(RETAIN(myPathSeps));
|
||||||
sepMember = (BOOL (*)(NSCharacterSet*, SEL, unichar))
|
|
||||||
[myPathSeps methodForSelector: @selector(characterIsMember:)];
|
|
||||||
}
|
}
|
||||||
return myPathSeps;
|
return myPathSeps;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL
|
inline static BOOL
|
||||||
pathSepMember(unichar c)
|
pathSepMember(unichar c)
|
||||||
{
|
{
|
||||||
if (sepMember == 0)
|
|
||||||
pathSeps();
|
#if defined(__MINGW__)
|
||||||
|
if (c == (unichar)'\\' || c == (unichar)'/')
|
||||||
return (*sepMember)(myPathSeps, @selector(characterIsMember:), c);
|
#else
|
||||||
|
if (c == (unichar)'/')
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Convert a high-low surrogate pair into Unicode scalar code-point */
|
/* Convert a high-low surrogate pair into Unicode scalar code-point */
|
||||||
static inline gsu32
|
static inline gsu32
|
||||||
surrogatePairValue(unichar high, unichar low)
|
surrogatePairValue(unichar high, unichar low)
|
||||||
|
@ -2926,11 +2934,11 @@ handle_printf_atsign (FILE *stream,
|
||||||
{
|
{
|
||||||
NSMutableArray *a;
|
NSMutableArray *a;
|
||||||
NSArray *r;
|
NSArray *r;
|
||||||
int i;
|
unsigned i, count = [paths count];
|
||||||
|
|
||||||
a = [[NSMutableArray allocWithZone: NSDefaultMallocZone()]
|
a = [[NSMutableArray allocWithZone: NSDefaultMallocZone()]
|
||||||
initWithCapacity: [paths count]];
|
initWithCapacity: count];
|
||||||
for (i = 0; i < [paths count]; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
NSString *s = [paths objectAtIndex: i];
|
NSString *s = [paths objectAtIndex: i];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue