Differences From Artifact [c2dcb9f429]:
- File src/OFSet.m — part of check-in [6228b691b5] at 2022-06-12 06:27:14 on branch trunk — Remove a few useless methods (user: js, size: 8028) [annotate] [blame] [check-ins using] [more...]
To Artifact [bebf07d610]:
- File
src/OFSet.m
— part of check-in
[27d8eb922d]
at
2023-07-15 23:44:25
on branch trunk
— Never set mutationsPtr to self
The Apple runtime can store the retain count in isa, so
retaining/releasing an object would suddenly make it seem like it was
mutated. (user: js, size: 7177) [annotate] [blame] [check-ins using] [more...]
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * |
︙ | ︙ | |||
18 19 20 21 22 23 24 | #include <stdlib.h> #import "OFSet.h" #import "OFArray.h" #import "OFMapTableSet.h" #import "OFNull.h" #import "OFString.h" | < | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #include <stdlib.h> #import "OFSet.h" #import "OFArray.h" #import "OFMapTableSet.h" #import "OFNull.h" #import "OFString.h" static struct { Class isa; } placeholder; @interface OFSetPlaceholder: OFSet @end |
︙ | ︙ | |||
68 69 70 71 72 73 74 | - (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { return (id)[[OFMapTableSet alloc] initWithObject: firstObject arguments: arguments]; } | < < < < < | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | - (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { return (id)[[OFMapTableSet alloc] initWithObject: firstObject arguments: arguments]; } - (instancetype)retain { return self; } - (instancetype)autorelease { |
︙ | ︙ | |||
190 191 192 193 194 195 196 | } - (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { OF_INVALID_INIT_METHOD } | < < < < < | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | } - (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { OF_INVALID_INIT_METHOD } - (size_t)count { OF_UNRECOGNIZED_SELECTOR } - (id)valueForKey: (OFString *)key { |
︙ | ︙ | |||
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | OF_UNRECOGNIZED_SELECTOR } - (int)countByEnumeratingWithState: (OFFastEnumerationState *)state objects: (id *)objects count: (int)count { OFEnumerator *enumerator; int i; memcpy(&enumerator, state->extra, sizeof(enumerator)); if (enumerator == nil) { enumerator = [self objectEnumerator]; memcpy(state->extra, &enumerator, sizeof(enumerator)); } state->itemsPtr = objects; | > | | 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | OF_UNRECOGNIZED_SELECTOR } - (int)countByEnumeratingWithState: (OFFastEnumerationState *)state objects: (id *)objects count: (int)count { static unsigned long dummyMutations; OFEnumerator *enumerator; int i; memcpy(&enumerator, state->extra, sizeof(enumerator)); if (enumerator == nil) { enumerator = [self objectEnumerator]; memcpy(state->extra, &enumerator, sizeof(enumerator)); } state->itemsPtr = objects; state->mutationsPtr = &dummyMutations; for (i = 0; i < count; i++) { id object = [enumerator nextObject]; if (object == nil) return i; |
︙ | ︙ | |||
358 359 360 361 362 363 364 | for (id object in self) if ([set containsObject: object]) return true; return false; } | < < < < < < < < < < < < < < < < < < < < < < < < < | 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | for (id object in self) if ([set containsObject: object]) return true; return false; } - (OFSet *)setByAddingObjectsFromSet: (OFSet *)set { OFMutableSet *new = [[self mutableCopy] autorelease]; [new unionSet: set]; [new makeImmutable]; return new; } |
︙ | ︙ |