Differences From Artifact [522c9d1fef]:
- File src/OFDictionary_hashtable.m — part of check-in [57a6e8ef79] at 2013-03-30 20:07:08 on branch trunk — Improve code readability. (user: js, size: 9393) [annotate] [blame] [check-ins using]
To Artifact [cf3019ae25]:
- File
src/OFDictionary_hashtable.m
— part of check-in
[3d16a30f41]
at
2013-06-22 12:12:36
on branch trunk
— Rework exceptions.
This mostly removes the argument for the class in which the exception
occurred. As backtraces were recently added for all platforms, the
passed class does not give any extra information on where the exception
occurred anymore.This also removes a few other arguments which were not too helpful. In
the past, the idea was to pass as many arguments as possible so that it
is easier to find the origin of the exception. However, as backtraces
are a much better way to find the origin, those are not useful anymore
and just make the exception more cumbersome to use. The rule is now to
only pass arguments that might help in recovering from the exception or
provide information that is otherwise not easily accessible. (user: js, size: 8905) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
196 197 198 199 200 201 202 | va_list argumentsCopy; id key, object; size_t i, count; va_copy(argumentsCopy, arguments); if (firstKey == nil) | | < < | < < | < < | < < | 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | va_list argumentsCopy; id key, object; size_t i, count; va_copy(argumentsCopy, arguments); if (firstKey == nil) @throw [OFInvalidArgumentException exception]; key = firstKey; if ((object = va_arg(arguments, id)) == nil) @throw [OFInvalidArgumentException exception]; count = 1; for (; va_arg(argumentsCopy, id) != nil; count++); if (count % 2 != 0) @throw [OFInvalidArgumentException exception]; count /= 2; _mapTable = [[OFMapTable alloc] initWithKeyFunctions: keyFunctions valueFunctions: valueFunctions capacity: count]; [_mapTable setValue: object forKey: key]; for (i = 1; i < count; i++) { key = va_arg(arguments, id); object = va_arg(arguments, id); if (key == nil || object == nil) @throw [OFInvalidArgumentException exception]; [_mapTable setValue: object forKey: key]; } } @catch (id e) { [self release]; @throw e; |
︙ | ︙ | |||
261 262 263 264 265 266 267 | keys = [element elementsForName: @"key" namespace: OF_SERIALIZATION_NS]; objects = [element elementsForName: @"object" namespace: OF_SERIALIZATION_NS]; if ([keys count] != [objects count]) | | < | < | 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | keys = [element elementsForName: @"key" namespace: OF_SERIALIZATION_NS]; objects = [element elementsForName: @"object" namespace: OF_SERIALIZATION_NS]; if ([keys count] != [objects count]) @throw [OFInvalidFormatException exception]; _mapTable = [[OFMapTable alloc] initWithKeyFunctions: keyFunctions valueFunctions: valueFunctions capacity: [keys count]]; keyEnumerator = [keys objectEnumerator]; objectEnumerator = [objects objectEnumerator]; while ((keyElement = [keyEnumerator nextObject]) != nil && (objectElement = [objectEnumerator nextObject]) != nil) { void *pool2 = objc_autoreleasePoolPush(); OFXMLElement *key, *object; key = [[keyElement elementsForNamespace: OF_SERIALIZATION_NS] firstObject]; object = [[objectElement elementsForNamespace: OF_SERIALIZATION_NS] firstObject]; if (key == nil || object == nil) @throw [OFInvalidFormatException exception]; [_mapTable setValue: [object objectByDeserializing] forKey: [key objectByDeserializing]]; objc_autoreleasePoolPop(pool2); } |
︙ | ︙ | |||
309 310 311 312 313 314 315 | [_mapTable dealloc]; [super dealloc]; } - (id)objectForKey: (id)key { | < < < | < < < < < < < | 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | [_mapTable dealloc]; [super dealloc]; } - (id)objectForKey: (id)key { return [_mapTable valueForKey: key]; } - (size_t)count { return [_mapTable count]; } |
︙ | ︙ | |||
454 455 456 457 458 459 460 | @try { [_mapTable enumerateKeysAndValuesUsingBlock: ^ (void *key, void *value, bool *stop) { block(key, value, stop); }]; } @catch (OFEnumerationMutationException *e) { @throw [OFEnumerationMutationException | < | | 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | @try { [_mapTable enumerateKeysAndValuesUsingBlock: ^ (void *key, void *value, bool *stop) { block(key, value, stop); }]; } @catch (OFEnumerationMutationException *e) { @throw [OFEnumerationMutationException exceptionWithObject: self]; } } #endif - (uint32_t)hash { return [_mapTable hash]; } @end |