Differences From Artifact [64cc71dd61]:
- File src/OFDictionary_hashtable.m — part of check-in [8892ae9fcc] at 2012-07-12 01:28:46 on branch trunk — Don't access isa directly. (user: js, size: 18063) [annotate] [blame] [check-ins using]
To Artifact [ce4770d88a]:
- File
src/OFDictionary_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: 17994) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
22 23 24 25 26 27 28 | #import "OFDictionary_hashtable.h" #import "OFMutableDictionary_hashtable.h" #import "OFEnumerator.h" #import "OFArray.h" #import "OFString.h" #import "OFXMLElement.h" | < > | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #import "OFDictionary_hashtable.h" #import "OFMutableDictionary_hashtable.h" #import "OFEnumerator.h" #import "OFArray.h" #import "OFString.h" #import "OFXMLElement.h" #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFNotImplementedException.h" #import "OFOutOfRangeException.h" #import "autorelease.h" #import "macros.h" struct of_dictionary_hashtable_bucket of_dictionary_hashtable_deleted_bucket = {}; #define DELETED &of_dictionary_hashtable_deleted_bucket @implementation OFDictionary_hashtable |
︙ | ︙ | |||
120 121 122 123 124 125 126 | [dictionary class] == [OFMutableDictionary_hashtable class]) return [self _initWithDictionary: dictionary copyKeys: YES]; self = [super init]; @try { | | | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | [dictionary class] == [OFMutableDictionary_hashtable class]) return [self _initWithDictionary: dictionary copyKeys: YES]; self = [super init]; @try { void *pool; OFEnumerator *enumerator; id key; uint32_t i, newSize; count = [dictionary count]; if (count > UINT32_MAX) |
︙ | ︙ | |||
147 148 149 150 151 152 153 | count: newSize]; for (i = 0; i < newSize; i++) data[i] = NULL; size = newSize; | | < > | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | count: newSize]; for (i = 0; i < newSize; i++) data[i] = NULL; size = newSize; pool = objc_autoreleasePoolPush(); enumerator = [dictionary keyEnumerator]; while ((key = [enumerator nextObject]) != nil) { uint32_t hash, last; struct of_dictionary_hashtable_bucket *bucket; id object; hash = [key hash]; last = size; |
︙ | ︙ | |||
183 184 185 186 187 188 189 | bucket->key = [key copy]; bucket->object = [object retain]; bucket->hash = hash; data[i] = bucket; } | | | 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | bucket->key = [key copy]; bucket->object = [object retain]; bucket->hash = hash; data[i] = bucket; } objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
497 498 499 500 501 502 503 | return self; } - initWithSerialization: (OFXMLElement*)element { @try { | < | | 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | return self; } - initWithSerialization: (OFXMLElement*)element { @try { void *pool = objc_autoreleasePoolPush(); OFMutableDictionary *dictionary; OFArray *keys, *objects; OFEnumerator *keyEnumerator, *objectEnumerator; OFXMLElement *keyElement, *objectElement; if ((![[element name] isEqual: @"OFDictionary"] && ![[element name] isEqual: @"OFMutableDictionary"]) || |
︙ | ︙ | |||
524 525 526 527 528 529 530 | if ([keys count] != [objects count]) @throw [OFInvalidFormatException exceptionWithClass: [self class]]; keyEnumerator = [keys objectEnumerator]; objectEnumerator = [objects objectEnumerator]; | < < > | | | 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 | if ([keys count] != [objects count]) @throw [OFInvalidFormatException exceptionWithClass: [self class]]; 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 exceptionWithClass: [self class]]; [dictionary setObject: [object objectByDeserializing] forKey: [key objectByDeserializing]]; objc_autoreleasePoolPop(pool2); } self = [self initWithDictionary: dictionary]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ |