- NSEntityDescription fix for updated objc runtime

- Removed NSMethodSignature cache, not thread safe.
- Removed NSIndexPath cache, not thread safe.
- Moved NSPropertyListReader_vintage class caching into instance.
- Removed caching of page size in NSPageSize() for linux/solaris/darwin.
- objc cache entry initialization tweaks
- removed unused _selectorCount
- Moved NSBundle static _sharedLookInDirectoriesArray to per-instance
- Moved NSProcessInfo static _counter and _counterLock to per instance
- Uncommented NSClassDescription use of @synchronized as the compiler can handle it now.
- Remove _fontHolder from NSInterfacePartAttributedString
- declared some variables with static scope as static
This commit is contained in:
Christopher Lloyd 2009-02-25 01:13:55 +00:00
parent ee099a0287
commit 0138291acf
28 changed files with 109 additions and 219 deletions

View File

@ -8,6 +8,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <ApplicationServices/CGGeometry.h>
CGRect CGRectZero={{0,0},{0,0}};
CGPoint CGPointZero={0,0};
CGSize CGSizeZero={0,0};
const CGRect CGRectZero={{0,0},{0,0}};
const CGPoint CGPointZero={0,0};
const CGSize CGSizeZero={0,0};

View File

@ -39,7 +39,7 @@
@implementation KGContext_builtin
BOOL _isAvailable=NO;
static BOOL _isAvailable=NO;
+(void)initialize {
_isAvailable=[[NSUserDefaults standardUserDefaults] boolForKey:@"CGEnableBuiltin"];

View File

@ -14,7 +14,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
@implementation KGImageSource
+(KGImageSource *)newImageSourceWithDataProvider:(KGDataProvider *)provider options:(NSDictionary *)options {
static NSString *classes[]={
NSString *classes[]={
@"KGImageSource_PNG",
@"KGImageSource_TIFF",
@"KGImageSource_JPEG",

View File

@ -5,8 +5,6 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
// Original - Christopher Lloyd <cjwl@objc.net>
#import <AppKit/NSInterfacePartAttributedString.h>
#import <AppKit/NSAttributedString.h>
#import <AppKit/NSStringDrawing.h>
@ -15,12 +13,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
@implementation NSInterfacePartAttributedString
static NSMutableArray *_fontHolder;
+(void)initialize {
_fontHolder=[NSMutableArray new];
}
-initWithCharacter:(unichar)character fontName:(NSString *)fontName pointSize:(float)pointSize color:(NSColor *)color {
NSString *string=[NSString stringWithCharacters:&character length:1];
NSFont *font=[NSFont fontWithName:fontName size:pointSize];
@ -29,9 +21,6 @@ static NSMutableArray *_fontHolder;
color,NSForegroundColorAttributeName,
nil];
if(![_fontHolder containsObject:font])
[_fontHolder addObject:font];
_attributedString=[[NSAttributedString alloc] initWithString:string attributes:attributes];
return self;

View File

@ -14,8 +14,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <Foundation/NSKeyValueCoding.h>
#import <Foundation/NSEnumerator.h>
NSMutableDictionary *bindersForObjects=nil;
NSDictionary *defaultBindingOptions;
static NSMutableDictionary *bindersForObjects=nil;
static NSDictionary *defaultBindingOptions;
#pragma mark -
#pragma mark Binding Option Keys

View File

@ -15,9 +15,9 @@ typedef NSPoint CGPoint;
typedef NSSize CGSize;
typedef NSRect CGRect;
COREGRAPHICS_EXPORT CGRect CGRectZero;
COREGRAPHICS_EXPORT CGPoint CGPointZero;
COREGRAPHICS_EXPORT CGSize CGSizeZero;
COREGRAPHICS_EXPORT const CGRect CGRectZero;
COREGRAPHICS_EXPORT const CGPoint CGPointZero;
COREGRAPHICS_EXPORT const CGSize CGSizeZero;
static inline CGRect CGRectMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height) {
return NSMakeRect(x,y,width,height);

View File

@ -95,6 +95,20 @@
remoteGlobalIDString = FED70FB70C3C09C7000CBE5B;
remoteInfo = "Foundation-Darwin-ppc";
};
FE6E110C0F4F8F6600C65544 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = E2F48FA10DC80FAE00310CCE /* AppKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = C889770C0EA0BF3100D0A0A2 /* AppKit.framework */;
remoteInfo = "AppKit-Linux-i386";
};
FE6E110E0F4F8F6600C65544 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = E2F48FA10DC80FAE00310CCE /* AppKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = C8A2E5730F07EA1F0054397C /* AppKit.framework */;
remoteInfo = "AppKit-Darwin-i386";
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
@ -252,6 +266,8 @@
isa = PBXGroup;
children = (
E2F48FA60DC80FAE00310CCE /* AppKit.framework */,
FE6E110D0F4F8F6600C65544 /* AppKit.framework */,
FE6E110F0F4F8F6600C65544 /* AppKit.framework */,
);
name = Products;
sourceTree = "<group>";
@ -387,6 +403,20 @@
remoteRef = FE59F3170D54301D00D54A25 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
FE6E110D0F4F8F6600C65544 /* AppKit.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = AppKit.framework;
remoteRef = FE6E110C0F4F8F6600C65544 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
FE6E110F0F4F8F6600C65544 /* AppKit.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = AppKit.framework;
remoteRef = FE6E110E0F4F8F6600C65544 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */

View File

@ -128,7 +128,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
struct objc_method_list *newMethodList
= malloc(sizeof(struct objc_method_list)
+ [newMethods count] * sizeof(struct objc_method));
newMethodList->method_next = NULL;
newMethodList->method_count = [newMethods count];
NSInteger i = 0;
for(NSValue *methodValue in newMethods) {

View File

@ -18,6 +18,7 @@ FOUNDATION_EXPORT NSString *NSLoadedClasses;
NSString *_resourcePath;
NSDictionary *_infoDictionary;
NSString *_executablePath;
NSArray *_lookInDirectories;
BOOL _isLoaded;
}

View File

@ -389,18 +389,18 @@ static NSMapTable *pathToObject=NULL;
return 0;
}
static NSArray *_sharedLookInDirectoriesArray = nil;
-(NSArray *)lookInDirectories {
if (_sharedLookInDirectoriesArray == nil)
if (_lookInDirectories == nil)
{
// FIXME: This should be based on language preference order, and tested for presence in bundle before adding
NSString *language = [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode];
if ([language isEqualToString:@"English"])
_sharedLookInDirectoriesArray = [[NSArray arrayWithObjects:@"English.lproj", @"", nil] retain];
_lookInDirectories = [[NSArray arrayWithObjects:@"English.lproj", @"", nil] retain];
else
_sharedLookInDirectoriesArray = [[NSArray arrayWithObjects:[language stringByAppendingPathExtension:@"lproj"], @"English.lproj", @"", nil] retain];
_lookInDirectories = [[NSArray arrayWithObjects:[language stringByAppendingPathExtension:@"lproj"], @"English.lproj", @"", nil] retain];
}
return _sharedLookInDirectoriesArray;
return _lookInDirectories;
}
-(NSString *)pathForResourceFile:(NSString *)file inDirectory:(NSString *)directory {

View File

@ -19,8 +19,10 @@ static NSMutableDictionary* classDescriptionCache = nil;
+ (NSClassDescription*) classDescriptionForClass: (Class) class
{
// @synchronized(self) { // should be in, but bus error in gcc
id result = [classDescriptionCache objectForKey:
id result;
@synchronized(self) {
result = [classDescriptionCache objectForKey:
NSStringFromClass(class)];
if (!result) {
[[NSNotificationCenter defaultCenter] postNotificationName:
@ -28,28 +30,28 @@ NSClassDescriptionNeededForClassNotification object: class];
}
result = [classDescriptionCache objectForKey:
NSStringFromClass(class)];
//}
}
return result;
}
+ (void)invalidateClassDescriptionCache
{
// @synchronized(self) { // should be in, but bus error in gcc
@synchronized(self) {
[classDescriptionCache release];
classDescriptionCache = nil;
//}
}
}
+ (void) registerClassDescription: (NSClassDescription*)description
forClass: (Class) class
{
// @synchronized(self) { // should be in, but bus error in gcc
@synchronized(self) {
if (!classDescriptionCache) {
classDescriptionCache = [[NSMutableDictionary alloc] init];
}
[classDescriptionCache setObject: description forKey:
NSStringFromClass(class)];
//}
}
}
-(NSArray *)attributeKeys {

View File

@ -9,13 +9,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <Foundation/NSDebug.h>
#import <Foundation/NSString.h>
#if 0
#warning !!!!!!!!!!!!!!!!ZOMBIES ENABLED!!!!!!!!!!!!!!!!
BOOL NSZombieEnabled=YES;
#else
BOOL NSZombieEnabled=NO;
#endif
BOOL NSDebugEnabled=NO;
const char* _NSPrintForDebugger(id object) {

View File

@ -15,16 +15,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
@implementation NSIndexPath
#define PATH_CACHE_SIZE 512 // adjust, if not suitable in praxis
static NSMutableSet* pathCache = nil;
+ (void) initialize {
if (pathCache == nil) {
pathCache = [[NSMutableSet alloc] init];
}
}
+ (NSIndexPath*) indexPathWithIndex: (unsigned int) index {
return [[[self alloc] initWithIndexes: &index length: 1] autorelease];
}
@ -49,26 +39,9 @@ static NSMutableSet* pathCache = nil;
_hash = _hash*2 + _indexes[i];
}
_hash = 2*_hash + _length;
id cachedInstance = [pathCache member: self];
_indexes = NULL; // make sure, free() is not called
if (cachedInstance) {
[self release];
return cachedInstance;
}
// copy indexes only, if no cached instance exists:
_indexes = malloc(length*sizeof(unsigned int));
_indexes = malloc(length*sizeof(unsigned int));
memcpy(_indexes, indexes, length*sizeof(unsigned int));
// Make sure, pathCache does not grow larger than 1024 elements. Should be do that?
if ([pathCache count] >= PATH_CACHE_SIZE) {
[pathCache removeObject: [pathCache anyObject]];
}
[pathCache addObject: self];
}
}
return self;
}

View File

@ -26,7 +26,7 @@ typedef struct LockChain
struct LockChain *next;
} LockChain;
LockChain *allLocks[NUM_CHAINS]={0};
static LockChain *allLocks[NUM_CHAINS]={0};
void _NSInitializeSynchronizedDirective()
{

View File

@ -11,7 +11,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
@class NSString,NSMutableArray;
@interface NSMethodSignature : NSObject {
const char *_typesCString;
char *_typesCString;
NSString *_returnType;
NSMutableArray *_types;
void* _closure;

View File

@ -16,48 +16,15 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
@implementation NSMethodSignature
static unsigned stringHash(NSMapTable *table,const void *data){
const char *s=data;
if(s!=NULL)
return NSStringHashZeroTerminatedASCII(s);
return 0;
}
static BOOL stringIsEqual(NSMapTable *tabl,const void *data1,const void *data2){
if (data1 == data2)
return YES;
if (!data1)
return ! strlen ((char *) data2);
if (!data2)
return ! strlen ((char *) data1);
if (((char *) data1)[0] != ((char *) data2)[0])
return NO;
return (strcmp ((char *) data1, (char *) data2)) ? NO : YES;
}
static NSMapTableKeyCallBacks keyCallBacks = {
stringHash,stringIsEqual,NULL,NULL,NULL,NULL
};
static NSMapTable *_cache=NULL;
+(void)initialize {
if(self==[NSMethodSignature class])
_cache=NSCreateMapTable(keyCallBacks,NSObjectMapValueCallBacks,0);
}
-initWithTypes:(const char *)types {
const char *next=types,*last=types;
const char *next,*last;
unsigned size,align;
BOOL first=YES;
_typesCString=types;
// not guaranteed that types is static
_typesCString=NSZoneMalloc(NULL,strlen(types)+1);
strcpy(_typesCString,types);
next=last=_typesCString;
_returnType=nil;
_types=[[NSMutableArray allocWithZone:NULL] init];
@ -84,6 +51,7 @@ static NSMapTable *_cache=NULL;
}
-(void)dealloc {
NSZoneFree(NULL,_typesCString);
[_returnType release];
[_types release];
if([self respondsToSelector:@selector(_deallocateClosure)])
@ -91,32 +59,8 @@ static NSMapTable *_cache=NULL;
[super dealloc];
}
NSMethodSignature *NSMethodSignatureWithTypes(const char *types) {
NSMethodSignature *entry;
char *typesCopy;
if(_cache==NULL)
[NSMethodSignature class]; // initialize
entry=NSMapGet(_cache,types);
if(entry==nil){
entry=[[NSMethodSignature allocWithZone:NULL] initWithTypes:types];
// not guaranteed that types is static
typesCopy=NSZoneMalloc(NULL,strlen(types)+1);
strcpy(typesCopy,types);
NSMapInsert(_cache,typesCopy,entry);
[entry release];
}
return entry;
}
+(NSMethodSignature *)signatureWithObjCTypes:(const char *)types {
return NSMethodSignatureWithTypes(types);
return [[[NSMethodSignature allocWithZone:NULL] initWithTypes:types] autorelease];
}
-(NSString *)description {
@ -124,7 +68,7 @@ NSMethodSignature *NSMethodSignatureWithTypes(const char *types) {
}
-(unsigned)hash {
return stringHash(NULL,_typesCString);
return NSStringHashZeroTerminatedASCII(_typesCString);
}
-(BOOL)isEqual:otherObject {

View File

@ -19,8 +19,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <Foundation/NSRaise.h>
#import <Foundation/ObjCClass.h>
extern NSMethodSignature *NSMethodSignatureWithTypes(const char *types);
@interface NSInvocation(private)
+(NSInvocation *)invocationWithMethodSignature:(NSMethodSignature *)signature arguments:(void *)arguments;
@end
@ -86,7 +84,7 @@ extern NSMethodSignature *NSMethodSignatureWithTypes(const char *types);
+(NSMethodSignature *)instanceMethodSignatureForSelector:(SEL)selector {
const char *types=OBJCTypesForSelector(self,selector);
return (types==NULL)?(NSMethodSignature *)nil:NSMethodSignatureWithTypes(types);
return (types==NULL)?(NSMethodSignature *)nil:[NSMethodSignature signatureWithObjCTypes:types];
}
+(BOOL)resolveClassMethod:(SEL)selector {
@ -184,7 +182,7 @@ extern NSMethodSignature *NSMethodSignatureWithTypes(const char *types);
-(NSMethodSignature *)methodSignatureForSelector:(SEL)selector {
const char *types=OBJCTypesForSelector(isa,selector);
return (types==NULL)?(NSMethodSignature *)nil:NSMethodSignatureWithTypes(types);
return (types==NULL)?(NSMethodSignature *)nil:[NSMethodSignature signatureWithObjCTypes:types];
}
-(void)forwardInvocation:(NSInvocation *)invocation {

View File

@ -8,7 +8,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <Foundation/NSObject.h>
@class NSArray,NSDictionary;
@class NSArray,NSDictionary,NSLock;
enum {
NSWindowsNTOperatingSystem=1,
@ -22,6 +22,8 @@ enum {
NSArray *_arguments;
NSString *_hostName;
NSString *_processName;
NSInteger _counter;
NSLock *_counterLock;
}
+(NSProcessInfo *)processInfo;

View File

@ -5,8 +5,6 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
// Original - Christopher Lloyd <cjwl@objc.net>
#import <Foundation/NSProcessInfo.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h>
@ -23,20 +21,12 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
int NSProcessInfoArgc=0;
const char * const *NSProcessInfoArgv=NULL;
static NSLock *_counterLock=nil;
+(void)initialize {
if(self==[NSProcessInfo class])
_counterLock=[NSLock new];
}
-(int)incrementCounter {
static int counter=0;
-(NSInteger)incrementCounter {
int result;
[_counterLock lock];
counter++;
result=counter;
_counter++;
result=_counter;
[_counterLock unlock];
return result;
@ -51,6 +41,8 @@ static NSLock *_counterLock=nil;
_arguments=nil;
_hostName=nil;
_processName=nil;
_counter=0;
_counterLock=[NSLock new];
return self;
}

View File

@ -26,6 +26,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
unsigned _index;
unsigned _lineNumber;
Class _stringClass;
Class _dictionaryClass;
Class _arrayClass;
}
+(NSObject *)propertyListFromData:(NSData *)data;

View File

@ -15,21 +15,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <Foundation/NSScanner.h>
#import <Foundation/NSNumber.h>
static Class NSStringClass=nil;
static Class NSMutableDictionaryClass=nil;
static Class NSMutableArrayClass=nil;
@implementation NSPropertyListReader_vintage
+(void)initialize {
if(self==[NSPropertyListReader_vintage class])
{
NSStringClass=[NSString class];
NSMutableDictionaryClass=[NSMutableDictionary class];
NSMutableArrayClass=[NSMutableArray class];
}
}
-initWithData:(NSData *)data {
_data=[data retain];
_length=[_data length];
@ -46,6 +33,10 @@ static Class NSMutableArrayClass=nil;
_index=0;
_lineNumber=1;
_stringClass=[NSString class];
_dictionaryClass=[NSMutableDictionary class];
_arrayClass=[NSMutableArray class];
return self;
}
@ -128,7 +119,7 @@ static inline void appendCharacter(NSPropertyListReader_vintage *self,unsigned c
-(id)convertValue:(id)value
{
if(![value isKindOfClass:NSStringClass])
if(![value isKindOfClass:_stringClass])
return value;
id scanner=[NSScanner scannerWithString:value];
@ -220,17 +211,17 @@ static inline void appendCharacter(NSPropertyListReader_vintage *self,unsigned c
object=popObject(self);
key=popObject(self);
if(![key isKindOfClass:NSStringClass]){
if(![key isKindOfClass:_stringClass]){
[key release];
[object release];
return [self internalError:NSStringClass];
return [self internalError:_stringClass];
}
dictionary=topObject(self);
if(![dictionary isKindOfClass:NSMutableDictionaryClass]){
if(![dictionary isKindOfClass:_dictionaryClass]){
[key release];
[object release];
return [self internalError:NSMutableDictionaryClass];
return [self internalError:_dictionaryClass];
}
[dictionary setObject:[self convertValue:object] forKey:key];
[key release];
@ -241,8 +232,8 @@ static inline void appendCharacter(NSPropertyListReader_vintage *self,unsigned c
if(expect!=EXPECT_KEY)
return [self parseError:expect:code info:info];
if(![topObject(self) isKindOfClass:NSMutableDictionaryClass])
return [self internalError:NSMutableDictionaryClass];
if(![topObject(self) isKindOfClass:_dictionaryClass])
return [self internalError:_dictionaryClass];
expect=(_stackSize==1)?EXPECT_EOF:EXPECT_SEPARATOR;
}
@ -263,9 +254,9 @@ static inline void appendCharacter(NSPropertyListReader_vintage *self,unsigned c
object=popObject(self);
array=topObject(self);
if(![array isKindOfClass:NSMutableArrayClass]){
if(![array isKindOfClass:_arrayClass]){
[object release];
return [self internalError:NSMutableArrayClass];
return [self internalError:_arrayClass];
}
[array addObject:[self convertValue:object]];
@ -285,9 +276,9 @@ static inline void appendCharacter(NSPropertyListReader_vintage *self,unsigned c
object=popObject(self);
array=topObject(self);
if(![array isKindOfClass:NSMutableArrayClass]){
if(![array isKindOfClass:_arrayClass]){
[object release];
return [self internalError:NSMutableArrayClass];
return [self internalError:_arrayClass];
}
if(object!=nil){

View File

@ -52,7 +52,7 @@ typedef struct {
RefCountBucket **buckets;
} RefCountTable;
OSSpinLock RefCountLock=0;
static OSSpinLock RefCountLock=0;
static inline RefCountTable *CreateRefCountTable() {
RefCountTable *table;

View File

@ -5,8 +5,6 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
// Original - David Young <daver@geeks.org>, Christopher Lloyd <cjwl@objc.net>
#import <Foundation/ObjCClass.h>
#import <Foundation/ObjCSelector.h>
#import "Protocol.h"
@ -128,23 +126,23 @@ static void OBJCRegisterSelectorsInClass(Class class) {
}
}
static void OBJCInitializeCacheEntry(OBJCMethodCacheEntry *entry){
static struct objc_method empty={
0,NULL,NULL
};
static inline void OBJCInitializeCacheEntryOffset(OBJCMethodCacheEntry *entry){
entry->offsetToNextEntry=-((long)entry);
entry->method=&empty;
}
static void OBJCCreateCacheForClass(Class class){
if(class->cache==NULL){
static struct objc_method empty={
0,NULL,NULL
};
int i;
class->cache=NSZoneCalloc(NULL,1,sizeof(OBJCMethodCache));
for(i=0;i<OBJCMethodCacheNumberOfEntries;i++){
OBJCInitializeCacheEntry(class->cache->table+i);
OBJCMethodCacheEntry *entry=class->cache->table+i;
OBJCInitializeCacheEntryOffset(entry);
entry->method=&empty;
}
}
}
@ -360,7 +358,7 @@ id OBJCMessageNil(id object,SEL message,...){
static OBJCMethodCacheEntry *allocateCacheEntry(){
OBJCMethodCacheEntry *result=NSZoneCalloc(NULL,1,sizeof(OBJCMethodCacheEntry));
OBJCInitializeCacheEntry(result);
OBJCInitializeCacheEntryOffset(result);
return result;
}

View File

@ -16,11 +16,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#define INITIAL_SELECTOR_TABLE_SIZE 4096 // Big System has about 3700 selectors
int selectorCount=0;
static OBJCHashTable *nameToNumber=NULL;
SEL OBJCRegisterSelectorName(const char *name){
SEL result;
@ -30,7 +27,6 @@ SEL OBJCRegisterSelectorName(const char *name){
result=(SEL)OBJCHashValueForKey(nameToNumber,name);
if(result==OBJCNilSelector){
selectorCount++;
result=(SEL)OBJCHashInsertValueForKey(nameToNumber,name, (char*)name);
}

View File

@ -290,7 +290,6 @@ invocation_closure(ffi_cif* cif, void* result, void** args, void* userdata)
@implementation NSMethodSignature (FFIClosure)
-(void)_deallocateClosure
{
NSLog(@"deallocate closure");
if(((ffi_cif*)_closureInfo)->arg_types)
NSZoneFree(NULL, ((ffi_cif*)_closureInfo)->arg_types);
if(_closureInfo)

View File

@ -10,12 +10,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <sys/unistd.h>
NSUInteger NSPageSize(void) {
static size_t pageSize = 0;
if (pageSize == 0)
pageSize = getpagesize();
return pageSize;
return getpagesize();
}
NSUInteger NSRealMemoryAvailable(void)

View File

@ -5,20 +5,13 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
// Original - David Young <daver@geeks.org>
#import <Foundation/Foundation.h>
#import <sys/sysinfo.h>
#import <sys/unistd.h>
// on Linux, page size is a compiled constant in the kernel
unsigned NSPageSize(void) {
static size_t pageSize = 0;
if (pageSize == 0)
pageSize = getpagesize();
return pageSize;
return getpagesize();
}
unsigned NSRealMemoryAvailable(void)

View File

@ -6,22 +6,12 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
// Original - David Young <daver@geeks.org>
#import <Foundation/Foundation.h>
#import <sys/sysinfo.h>
#import <sys/unistd.h>
/*
The page size is a system page size and need not be the same
as the underlying hardware page size.
*/
unsigned NSPageSize(void) {
static size_t pageSize = 0;
if (pageSize == 0)
pageSize = getpagesize();
return pageSize;
return getpagesize();
}
unsigned NSRealMemoryAvailable(void)