Differences From Artifact [38338532b1]:
- File src/OFSet_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: 5100) [annotate] [blame] [check-ins using]
To Artifact [6230f1526a]:
- File
src/OFSet_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: 5068) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
22 23 24 25 26 27 28 | #import "OFMutableSet_hashtable.h" #import "OFCountedSet_hashtable.h" #import "OFMutableDictionary_hashtable.h" #import "OFArray.h" #import "OFString.h" #import "OFNumber.h" #import "OFXMLElement.h" | < > > | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #import "OFMutableSet_hashtable.h" #import "OFCountedSet_hashtable.h" #import "OFMutableDictionary_hashtable.h" #import "OFArray.h" #import "OFString.h" #import "OFNumber.h" #import "OFXMLElement.h" #import "OFInvalidArgumentException.h" #import "autorelease.h" @implementation OFSet_hashtable - init { self = [super init]; @try { |
︙ | ︙ | |||
46 47 48 49 50 51 52 | } - initWithSet: (OFSet*)set { self = [self init]; @try { | | | | | | | | | | < < > | < | | | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | } - initWithSet: (OFSet*)set { self = [self init]; @try { void *pool = objc_autoreleasePoolPush(); OFNumber *one = [OFNumber numberWithSize: 1]; OFEnumerator *enumerator = [set objectEnumerator]; id object; /* * We can't just copy the dictionary as the specified set might * be a counted set, but we're just a normal set. */ while ((object = [enumerator nextObject]) != nil) [dictionary _setObject: one forKey: object copyKey: NO]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } - initWithArray: (OFArray*)array { self = [self init]; @try { void *pool = objc_autoreleasePoolPush(); OFNumber *one = [OFNumber numberWithSize: 1]; id *objects = [array objects]; size_t i, count = [array count]; for (i = 0; i < count; i++) [dictionary _setObject: one forKey: objects[i] copyKey: NO]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } - initWithObjects: (id const*)objects count: (size_t)count { self = [self init]; @try { void *pool = objc_autoreleasePoolPush(); OFNumber *one = [OFNumber numberWithSize: 1]; size_t i; for (i = 0; i < count; i++) [dictionary _setObject: one forKey: objects[i] copyKey: NO]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } - initWithObject: (id)firstObject arguments: (va_list)arguments { self = [self init]; @try { void *pool = objc_autoreleasePoolPush(); OFNumber *one = [OFNumber numberWithSize: 1]; id object; [dictionary _setObject: one forKey: firstObject copyKey: NO]; while ((object = va_arg(arguments, id)) != nil) [dictionary _setObject: one forKey: object copyKey: NO]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } - initWithSerialization: (OFXMLElement*)element { self = [self init]; @try { void *pool = objc_autoreleasePoolPush(); OFNumber *one; OFEnumerator *enumerator; OFXMLElement *child; if ((![[element name] isEqual: @"OFSet"] && ![[element name] isEqual: @"OFMutableSet"]) || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exceptionWithClass: [self class] selector: _cmd]; one = [OFNumber numberWithSize: 1]; enumerator = [[element elementsForNamespace: OF_SERIALIZATION_NS] objectEnumerator]; while ((child = [enumerator nextObject]) != nil) { void *pool2 = objc_autoreleasePoolPush(); [dictionary _setObject: one forKey: [child objectByDeserializing] copyKey: NO]; objc_autoreleasePoolPop(pool2); } objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ |