mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
Cache a few more classes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3545 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9089e9c641
commit
433e3fed93
2 changed files with 32 additions and 23 deletions
|
@ -71,10 +71,12 @@
|
||||||
* class with an underscore prepended.
|
* class with an underscore prepended.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/*
|
Class _NSArray;
|
||||||
* String classes
|
Class _NSMutableArray;
|
||||||
*/
|
Class _NSDictionary;
|
||||||
|
Class _NSMutableDictionary;
|
||||||
Class _NSString;
|
Class _NSString;
|
||||||
|
Class _NSMutableString;
|
||||||
Class _NSGString;
|
Class _NSGString;
|
||||||
Class _NSGMutableString;
|
Class _NSGMutableString;
|
||||||
Class _NSGCString;
|
Class _NSGCString;
|
||||||
|
@ -129,78 +131,79 @@ extern void *_fastMallocBuffer(unsigned size);
|
||||||
static INLINE BOOL
|
static INLINE BOOL
|
||||||
fastIsInstance(id obj)
|
fastIsInstance(id obj)
|
||||||
{
|
{
|
||||||
return CLS_ISCLASS(obj->class_pointer);
|
return CLS_ISCLASS(obj->class_pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE BOOL
|
static INLINE BOOL
|
||||||
fastIsClass(Class c)
|
fastIsClass(Class c)
|
||||||
{
|
{
|
||||||
return CLS_ISCLASS(c);
|
return CLS_ISCLASS(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE Class
|
static INLINE Class
|
||||||
fastClass(NSObject* obj)
|
fastClass(NSObject* obj)
|
||||||
{
|
{
|
||||||
return ((id)obj)->class_pointer;
|
return ((id)obj)->class_pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE Class
|
static INLINE Class
|
||||||
fastClassOfInstance(NSObject* obj)
|
fastClassOfInstance(NSObject* obj)
|
||||||
{
|
{
|
||||||
if (fastIsInstance((id)obj))
|
if (fastIsInstance((id)obj))
|
||||||
return fastClass(obj);
|
return fastClass(obj);
|
||||||
return Nil;
|
return Nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE Class
|
static INLINE Class
|
||||||
fastSuper(Class cls)
|
fastSuper(Class cls)
|
||||||
{
|
{
|
||||||
return cls->super_class;
|
return cls->super_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE BOOL
|
static INLINE BOOL
|
||||||
fastClassIsKindOfClass(Class c0, Class c1)
|
fastClassIsKindOfClass(Class c0, Class c1)
|
||||||
{
|
{
|
||||||
while (c0 != Nil) {
|
while (c0 != Nil)
|
||||||
if (c0 == c1)
|
{
|
||||||
return YES;
|
if (c0 == c1)
|
||||||
c0 = class_get_super_class(c0);
|
return YES;
|
||||||
|
c0 = class_get_super_class(c0);
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE BOOL
|
static INLINE BOOL
|
||||||
fastInstanceIsKindOfClass(NSObject *obj, Class c)
|
fastInstanceIsKindOfClass(NSObject *obj, Class c)
|
||||||
{
|
{
|
||||||
Class ic = fastClassOfInstance(obj);
|
Class ic = fastClassOfInstance(obj);
|
||||||
|
|
||||||
if (ic == Nil)
|
if (ic == Nil)
|
||||||
return NO;
|
return NO;
|
||||||
return fastClassIsKindOfClass(ic, c);
|
return fastClassIsKindOfClass(ic, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE const char*
|
static INLINE const char*
|
||||||
fastClassName(Class c)
|
fastClassName(Class c)
|
||||||
{
|
{
|
||||||
return c->name;
|
return c->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE int
|
static INLINE int
|
||||||
fastClassVersion(Class c)
|
fastClassVersion(Class c)
|
||||||
{
|
{
|
||||||
return c->version;
|
return c->version;
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE const char*
|
static INLINE const char*
|
||||||
fastSelectorName(SEL s)
|
fastSelectorName(SEL s)
|
||||||
{
|
{
|
||||||
return sel_get_name(s);
|
return sel_get_name(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE const char*
|
static INLINE const char*
|
||||||
fastSelectorTypes(SEL s)
|
fastSelectorTypes(SEL s)
|
||||||
{
|
{
|
||||||
return sel_get_type(s);
|
return sel_get_type(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -214,4 +217,5 @@ fastSelectorTypes(SEL s)
|
||||||
*/
|
*/
|
||||||
extern NSZone *fastZone(NSObject* obj);
|
extern NSZone *fastZone(NSObject* obj);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -58,7 +58,12 @@ void _fastBuildCache()
|
||||||
* Cache some classes for quick access later.
|
* Cache some classes for quick access later.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
_fastCls._NSArray = [NSArray class];
|
||||||
|
_fastCls._NSMutableArray = [NSMutableArray class];
|
||||||
|
_fastCls._NSDictionary = [NSDictionary class];
|
||||||
|
_fastCls._NSMutableDictionary = [NSMutableDictionary class];
|
||||||
_fastCls._NSString = [NSString class];
|
_fastCls._NSString = [NSString class];
|
||||||
|
_fastCls._NSMutableString = [NSMutableString class];
|
||||||
_fastCls._NSGString = [NSGString class];
|
_fastCls._NSGString = [NSGString class];
|
||||||
_fastCls._NSGMutableString = [NSGMutableString class];
|
_fastCls._NSGMutableString = [NSGMutableString class];
|
||||||
_fastCls._NSGCString = [NSGCString class];
|
_fastCls._NSGCString = [NSGCString class];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue