Differences From Artifact [b21568683c]:
- File
src/OFMutableDictionary_hashtable.m
— part of check-in
[1255f3a11a]
at
2012-08-10 20:08:24
on branch trunk
— Directly use the runtime's autorelease pools.
This greatly improves performance, as it gets rid of the overhead of
OFAutoreleasePool. (user: js, size: 7257) [annotate] [blame] [check-ins using]
To Artifact [c4df3481c5]:
- File src/OFMutableDictionary_hashtable.m — part of check-in [c137da5e5b] at 2012-09-16 15:27:48 on branch trunk — Prefix all private methods with OF_. (user: js, size: 7277) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
36 37 38 39 40 41 42 | { if (self == [OFMutableDictionary_hashtable class]) { dictionary = [OFDictionary_hashtable class]; [self inheritMethodsFromClass: dictionary]; } } | | | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | { if (self == [OFMutableDictionary_hashtable class]) { dictionary = [OFDictionary_hashtable class]; [self inheritMethodsFromClass: dictionary]; } } - (void)OF_resizeForCount: (size_t)newCount { size_t fullness = newCount * 4 / size; struct of_dictionary_hashtable_bucket **newData; uint32_t i, newSize; if (newCount > UINT32_MAX) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; |
︙ | ︙ | |||
93 94 95 96 97 98 99 | } [self freeMemory: data]; data = newData; size = newSize; } | | | | | 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | } [self freeMemory: data]; data = newData; size = newSize; } - (void)OF_setObject: (id)object forKey: (id)key copyKey: (BOOL)copyKey { uint32_t i, hash, last; id old; if (key == nil || object == nil) @throw [OFInvalidArgumentException exceptionWithClass: [self class] |
︙ | ︙ | |||
134 135 136 137 138 139 140 | } /* Key not in dictionary */ if (i >= last || data[i] == NULL || data[i] == DELETED || ![data[i]->key isEqual: key]) { struct of_dictionary_hashtable_bucket *bucket; | | | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | } /* Key not in dictionary */ if (i >= last || data[i] == NULL || data[i] == DELETED || ![data[i]->key isEqual: key]) { struct of_dictionary_hashtable_bucket *bucket; [self OF_resizeForCount: count + 1]; mutations++; last = size; for (i = hash & (size - 1); i < last && data[i] != NULL && data[i] != DELETED; i++); |
︙ | ︙ | |||
183 184 185 186 187 188 189 | data[i]->object = [object retain]; [old release]; } - (void)setObject: (id)object forKey: (id)key { | | | | | 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | data[i]->object = [object retain]; [old release]; } - (void)setObject: (id)object forKey: (id)key { [self OF_setObject: object forKey: key copyKey: YES]; } - (void)removeObjectForKey: (id)key { uint32_t i, hash, last; if (key == nil) |
︙ | ︙ | |||
212 213 214 215 216 217 218 | [data[i]->key release]; [data[i]->object release]; [self freeMemory: data[i]]; data[i] = DELETED; count--; mutations++; | | | 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | [data[i]->key release]; [data[i]->object release]; [self freeMemory: data[i]]; data[i] = DELETED; count--; mutations++; [self OF_resizeForCount: count]; return; } } if (i < last) return; |
︙ | ︙ | |||
236 237 238 239 240 241 242 | [data[i]->key release]; [data[i]->object release]; [self freeMemory: data[i]]; data[i] = DELETED; count--; mutations++; | | | 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | [data[i]->key release]; [data[i]->object release]; [self freeMemory: data[i]]; data[i] = DELETED; count--; mutations++; [self OF_resizeForCount: count]; return; } } } - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state |
︙ | ︙ |