Author: rfm
Date: Thu Jul 16 10:56:31 2015
New Revision: 38804
URL: http://svn.gna.org/viewcvs/gnustep?rev=38804&view=rev
Log:
Change method name as suggested by Niels
Modified:
libs/performance/trunk/GSCache.h
libs/performance/trunk/GSCache.m
Modified: libs/performance/trunk/GSCache.h
URL:
http://svn.gna.org/viewcvs/gnustep/libs/performance/trunk/GSCache.h?rev=38804&r1=38803&r2=38804&view=diff
==============================================================================
--- libs/performance/trunk/GSCache.h (original)
+++ libs/performance/trunk/GSCache.h Thu Jul 16 10:56:31 2015
@@ -55,6 +55,12 @@
* (and the copied keys are immutable) and implement the -hash and
* -isEqual: methods such that any two keys can be tested for equality
* and used as dictionary keys.<br />
+ * For object sizing we use the -sizeInBytesExcluding: method, which is
+ * declared in the GNUstep-base additions library headers as follows:<br />
+ * - (NSUInteger) sizeInBytesExcluding: (NSHashTable*)exclude;<br />
+ * If you wish to store objects in a size-limited cache, you should
+ * implement that method to return an appropriate size for the object
+ * you are caching.<br />
* NB. GSCache currently does not support subclassing ... use it as is
* or extend it via categories, but do not try to add instance variables.
*/
@@ -107,7 +113,7 @@
- (unsigned) maxObjects;
/**
- * Return the maximum tital size of items in the cache.<br />
+ * Return the maximum total size of items in the cache.<br />
* A value of zero means there is no limit.
*/
- (NSUInteger) maxSize;
@@ -262,12 +268,5 @@
@end
-/**
- * The -sizeInBytes: method is now declared in the GNUstep-base additions
- * header as follows:
- *
- * - (NSUInteger) sizeInBytes: (NSHashTable*)exclude;
- */
-
#endif
Modified: libs/performance/trunk/GSCache.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/performance/trunk/GSCache.m?rev=38804&r1=38803&r2=38804&view=diff
==============================================================================
--- libs/performance/trunk/GSCache.m (original)
+++ libs/performance/trunk/GSCache.m Thu Jul 16 10:56:31 2015
@@ -89,16 +89,16 @@
[object release];
[super dealloc];
}
-- (NSUInteger) sizeInBytes: (NSHashTable*)exclude
-{
- NSUInteger size = [super sizeInBytes: exclude];
-
- if (size > 0)
- {
- size += [key sizeInBytes: exclude];
- size += [object sizeInBytes: exclude];
- }
- return size;
+- (NSUInteger) sizeInBytesExcluding: (NSHashTable*)exclude
+{
+ NSUInteger bytes = [super sizeInBytesExcluding: exclude];
+
+ if (bytes > 0)
+ {
+ bytes += [key sizeInBytesExcluding: exclude];
+ bytes += [object sizeInBytesExcluding: exclude];
+ }
+ return bytes;
}
@end
@@ -261,7 +261,7 @@
e = NSEnumerateMapTable(my->contents);
while (NSNextMapEnumeratorPair(&e, (void**)&k, (void**)&i) != 0)
{
- size += [i->object sizeInBytes: my->exclude];
+ size += [i->object sizeInBytesExcluding: my->exclude];
}
NSEndMapTableEnumeration(&e);
if (my->maxSize > 0)
@@ -629,7 +629,7 @@
if (i->size == 0)
{
[my->exclude removeAllObjects];
- i->size = [i->object sizeInBytes: my->exclude];
+ i->size = [i->object sizeInBytesExcluding: my->exclude];
}
if (i->size > max)
{
@@ -709,7 +709,7 @@
= NSCreateHashTable(NSNonOwnedPointerHashCallBacks, 0);
}
[my->exclude removeAllObjects];
- addSize = [anObject sizeInBytes: my->exclude];
+ addSize = [anObject sizeInBytesExcluding: my->exclude];
if (addSize > maxSize)
{
addObjects = 0; // Object too big to cache.
@@ -805,17 +805,17 @@
[my->lock unlock];
}
-- (NSUInteger) sizeInBytes: (NSHashTable*)exclude
-{
- NSUInteger size = [super sizeInBytes: exclude];
+- (NSUInteger) sizeInBytesExcluding: (NSHashTable*)exclude
+{
+ NSUInteger size = [super sizeInBytesExcluding: exclude];
if (size > 0)
{
size += sizeof(Item)
- + [my->contents sizeInBytes: exclude]
- + [my->exclude sizeInBytes: exclude]
- + [my->name sizeInBytes: exclude]
- + [my->lock sizeInBytes: exclude];
+ + [my->contents sizeInBytesExcluding: exclude]
+ + [my->exclude sizeInBytesExcluding: exclude]
+ + [my->name sizeInBytesExcluding: exclude]
+ + [my->lock sizeInBytesExcluding: exclude];
}
return size;
}
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs