Differences From Artifact [f4dc3297f2]:
- File src/OFArray_adjacent.m — part of check-in [80d754522a] at 2011-08-13 10:04:27 on branch trunk — Introduce a naming scheme for classes implementing abstract classes. (user: js, size: 6303) [annotate] [blame] [check-ins using]
To Artifact [831950ce9b]:
- File
src/OFArray_adjacent.m
— part of check-in
[9e0ca2f627]
at
2011-09-11 12:15:55
on branch trunk
— Add OFArray_subarray and OFArray_adjacenSubarray.
These will prevent a copy of an immutable array when using
-[objectsInRange:]. (user: js, size: 6541) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #include "config.h" #include <stdarg.h> #import "OFArray_adjacent.h" #import "OFMutableArray_adjacent.h" #import "OFDataArray.h" #import "OFString.h" #import "OFXMLElement.h" #import "OFAutoreleasePool.h" #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" | > | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include "config.h" #include <stdarg.h> #import "OFArray_adjacent.h" #import "OFMutableArray_adjacent.h" #import "OFArray_adjacentSubarray.h" #import "OFDataArray.h" #import "OFString.h" #import "OFXMLElement.h" #import "OFAutoreleasePool.h" #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" |
︙ | ︙ | |||
267 268 269 270 271 272 273 | return OF_INVALID_INDEX; } - (OFArray*)objectsInRange: (of_range_t)range { | > > > > > > | | > | 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | return OF_INVALID_INDEX; } - (OFArray*)objectsInRange: (of_range_t)range { size_t count; if (![self isKindOfClass: [OFMutableArray class]]) return [OFArray_adjacentSubarray arrayWithArray: self range: range]; count = [array count]; if (range.start + range.length > count) @throw [OFOutOfRangeException newWithClass: isa]; return [OFArray arrayWithCArray: (id*)[array cArray] + range.start length: range.length]; } - (BOOL)isEqual: (id)object { OFArray *otherArray; id *cArray, *otherCArray; size_t i, count; if ([object class] != [OFArray_adjacent class] && [object class] != [OFMutableArray_adjacent class] && [object class] != [OFArray_adjacentSubarray class]) return [super isEqual: object]; otherArray = object; count = [array count]; if (count != [otherArray count]) |
︙ | ︙ |