More experimental code changes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@38801 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2015-07-15 15:26:29 +00:00
parent 3efbfa42e2
commit a8132a27d5
5 changed files with 62 additions and 9 deletions

View file

@ -406,12 +406,12 @@ static GC_descr nodeDesc; // Type descriptor for map node.
if (count > 0) if (count > 0)
{ {
NSAutoreleasePool *pool = [NSAutoreleasePool new]; NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSEnumerator *enumerator = [self keyEnumerator]; NSEnumerator *enumerator = [self objectEnumerator];
NSObject *k; NSObject *o;
while ((k = [enumerator nextObject]) != nil) while ((o = [enumerator nextObject]) != nil)
{ {
size += [k sizeInBytes: exclude]; size += [o sizeInBytes: exclude];
} }
[pool release]; [pool release];
} }

View file

@ -550,12 +550,12 @@ static Class mutableSetClass;
if (count > 0) if (count > 0)
{ {
NSAutoreleasePool *pool = [NSAutoreleasePool new]; NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSEnumerator *enumerator = [self keyEnumerator]; NSEnumerator *enumerator = [self objectEnumerator];
NSObject *k; NSObject *o;
while ((k = [enumerator nextObject]) != nil) while ((o = [enumerator nextObject]) != nil)
{ {
size += [k sizeInBytes: exclude]; size += [o sizeInBytes: exclude];
} }
[pool release]; [pool release];
} }

View file

@ -1090,7 +1090,7 @@ tsbytes(uintptr_t s, char *buf)
- (NSUInteger) sizeInBytes: (NSHashTable*)exclude - (NSUInteger) sizeInBytes: (NSHashTable*)exclude
{ {
if (0 == NSMapGet(exclude, self)) if (0 == NSHashGet(exclude, self))
{ {
return 0; return 0;
} }

View file

@ -29,6 +29,7 @@
#import "common.h" #import "common.h"
#import "Foundation/NSArray.h" #import "Foundation/NSArray.h"
#import "Foundation/NSAutoreleasePool.h"
#import "Foundation/NSDictionary.h" #import "Foundation/NSDictionary.h"
#import "Foundation/NSEnumerator.h" #import "Foundation/NSEnumerator.h"
#import "Foundation/NSException.h" #import "Foundation/NSException.h"
@ -1065,6 +1066,30 @@ const NSHashTableCallBacks NSPointerToStructHashCallBacks =
} }
} }
- (NSUInteger) sizeInBytes: (NSHashTable*)exclude
{
NSUInteger size = [super sizeInBytes: exclude];
if (size > 0)
{
NSUInteger count = [self count];
size += GSIMapSize(self);
if (count > 0)
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSEnumerator *enumerator = [self objectEnumerator];
NSObject *o;
while ((o = [enumerator nextObject]) != nil)
{
size += [o sizeInBytes: exclude];
}
[pool release];
}
}
return size;
}
@end @end
@implementation NSConcreteHashTableEnumerator @implementation NSConcreteHashTableEnumerator

View file

@ -29,6 +29,7 @@
#import "common.h" #import "common.h"
#import "Foundation/NSArray.h" #import "Foundation/NSArray.h"
#import "Foundation/NSAutoreleasePool.h"
#import "Foundation/NSDictionary.h" #import "Foundation/NSDictionary.h"
#import "Foundation/NSEnumerator.h" #import "Foundation/NSEnumerator.h"
#import "Foundation/NSException.h" #import "Foundation/NSException.h"
@ -1429,6 +1430,33 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
p->_x = self->cb.pf.v; p->_x = self->cb.pf.v;
return [p autorelease]; return [p autorelease];
} }
- (NSUInteger) sizeInBytes: (NSHashTable*)exclude
{
NSUInteger size = [super sizeInBytes: exclude];
if (size > 0)
{
NSUInteger count = [self count];
size += GSIMapSize(self);
if (count > 0)
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSEnumerator *enumerator = [self keyEnumerator];
NSObject *k;
while ((k = [enumerator nextObject]) != nil)
{
NSObject *o = [self objectForKey: k];
size += [k sizeInBytes: exclude] + [o sizeInBytes: exclude];
}
[pool release];
}
}
return size;
}
@end @end
@implementation NSConcreteMapTableKeyEnumerator @implementation NSConcreteMapTableKeyEnumerator