Differences From Artifact [0df520b24c]:
- File src/OFCountedSet.m — part of check-in [cfd374b906] at 2015-01-03 20:57:18 on branch trunk — Update copyright (user: js, size: 5920) [annotate] [blame] [check-ins using]
To Artifact [9e3f055893]:
- File
src/OFCountedSet.m
— part of check-in
[6b13727ce0]
at
2015-11-29 14:02:11
on branch trunk
— Make use of fast enumeration
Now that we require GCC >= 4.6 anyway, there's no more reason to not use
it anymore. (user: js, size: 5327) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
139 140 141 142 143 144 145 | OF_UNRECOGNIZED_SELECTOR } - (OFString*)description { OFMutableString *ret; void *pool; | < < < | | 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 | OF_UNRECOGNIZED_SELECTOR } - (OFString*)description { OFMutableString *ret; void *pool; size_t i, count = [self count]; if (count == 0) return @"{()}"; ret = [OFMutableString stringWithString: @"{(\n"]; pool = objc_autoreleasePoolPush(); i = 0; for (id object in self) { void *pool2 = objc_autoreleasePoolPush(); [ret appendString: object]; [ret appendFormat: @": %zu", [self countForObject: object]]; if (++i < count) [ret appendString: @",\n"]; |
︙ | ︙ | |||
188 189 190 191 192 193 194 | return [[OFCountedSet alloc] initWithSet: self]; } - (OFXMLElement*)XMLElementBySerializing { void *pool = objc_autoreleasePoolPush(); OFXMLElement *element; | < < < | < | 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | return [[OFCountedSet alloc] initWithSet: self]; } - (OFXMLElement*)XMLElementBySerializing { void *pool = objc_autoreleasePoolPush(); OFXMLElement *element; element = [OFXMLElement elementWithName: @"OFCountedSet" namespace: OF_SERIALIZATION_NS]; for (id <OFSerialization> object in self) { void *pool2 = objc_autoreleasePoolPush(); OFXMLElement *objectElement; OFString *count; count = [OFString stringWithFormat: @"%zu", |
︙ | ︙ | |||
240 241 242 243 244 245 246 | - (void)minusSet: (OFSet*)set { void *pool = objc_autoreleasePoolPush(); if ([set isKindOfClass: [OFCountedSet class]]) { OFCountedSet *countedSet = (OFCountedSet*)set; | < < | | < | < < < < < | | < | < < < | 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | - (void)minusSet: (OFSet*)set { void *pool = objc_autoreleasePoolPush(); if ([set isKindOfClass: [OFCountedSet class]]) { OFCountedSet *countedSet = (OFCountedSet*)set; for (id object in countedSet) { size_t i, count = [countedSet countForObject: object]; for (i = 0; i < count; i++) [self removeObject: object]; } } else for (id object in set) [self removeObject: object]; objc_autoreleasePoolPop(pool); } - (void)unionSet: (OFSet*)set { void *pool = objc_autoreleasePoolPush(); if ([set isKindOfClass: [OFCountedSet class]]) { OFCountedSet *countedSet = (OFCountedSet*)set; for (id object in countedSet) { size_t i, count = [countedSet countForObject: object]; for (i = 0; i < count; i++) [self addObject: object]; } } else for (id object in set) [self addObject: object]; objc_autoreleasePoolPop(pool); } @end |