optimise when setting nil object in cache

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/performance/trunk@24931 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2007-03-26 11:15:51 +00:00
parent 99b9ec51a3
commit c6f292b4c9
2 changed files with 7 additions and 3 deletions

View file

@ -160,14 +160,18 @@
- (void) setName: (NSString*)name; - (void) setName: (NSString*)name;
/** /**
* Sets (or replaces)the cached value for the specified key. * Sets (or replaces)the cached value for the specified key.<br />
* The value of anObject may be nil to remove any cached object
* for aKey.
*/ */
- (void) setObject: (id)anObject forKey: (NSString*)aKey; - (void) setObject: (id)anObject forKey: (NSString*)aKey;
/** /**
* Sets (or replaces)the cached value for the specified key, giving * Sets (or replaces)the cached value for the specified key, giving
* the value the specified lifetime (in seconds). A lifetime of zero * the value the specified lifetime (in seconds). A lifetime of zero
* means that the item is not limited by lifetime. * means that the item is not limited by lifetime.<br />
* The value of anObject may be nil to remove any cached object
* for aKey.
*/ */
- (void) setObject: (id)anObject - (void) setObject: (id)anObject
forKey: (NSString*)aKey forKey: (NSString*)aKey

View file

@ -467,7 +467,7 @@ static void removeItem(GSCacheItem *item, GSCacheItem **first)
NSMapRemove(my->contents, (void*)aKey); NSMapRemove(my->contents, (void*)aKey);
} }
if (maxSize > 0 || maxObjects > 0) if (addObjects > 0 && (maxSize > 0 || maxObjects > 0))
{ {
if (maxSize > 0) if (maxSize > 0)
{ {