Differences From Artifact [de78bb7da7]:
- File
src/OFArray.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: 13117) [annotate] [blame] [check-ins using]
To Artifact [a34fd71e38]:
- File
src/OFArray.m
— part of check-in
[f173477bef]
at
2011-09-19 16:34:04
on branch trunk
— Rename -[allocMemoryForNItems:withSize:] and friends.
It is now -[allocMemoryForNItems:ofSize:]. (user: js, size: 13113) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
258 259 260 261 262 263 264 | OFObject *container; size_t count; id *buffer; container = [[[OFObject alloc] init] autorelease]; count = [self count]; buffer = [container allocMemoryForNItems: [self count] | | | 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | OFObject *container; size_t count; id *buffer; container = [[[OFObject alloc] init] autorelease]; count = [self count]; buffer = [container allocMemoryForNItems: [self count] ofSize: sizeof(*buffer)]; [self getObjects: buffer inRange: of_range(0, count)]; return buffer; } |
︙ | ︙ | |||
342 343 344 345 346 347 348 | id *buffer; if (![self isKindOfClass: [OFMutableArray class]]) return [OFArray_subarray arrayWithArray: self range: range]; buffer = [self allocMemoryForNItems: range.length | | | 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | id *buffer; if (![self isKindOfClass: [OFMutableArray class]]) return [OFArray_subarray arrayWithArray: self range: range]; buffer = [self allocMemoryForNItems: range.length ofSize: sizeof(*buffer)]; @try { [self getObjects: buffer inRange: range]; ret = [OFArray arrayWithCArray: buffer length: range.length]; |
︙ | ︙ | |||
566 567 568 569 570 571 572 | #ifdef OF_HAVE_BLOCKS - (OFArray*)mappedArrayUsingBlock: (of_array_map_block_t)block { OFArray *ret; size_t count = [self count]; id *tmp = [self allocMemoryForNItems: count | | | 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 | #ifdef OF_HAVE_BLOCKS - (OFArray*)mappedArrayUsingBlock: (of_array_map_block_t)block { OFArray *ret; size_t count = [self count]; id *tmp = [self allocMemoryForNItems: count ofSize: sizeof(id)]; @try { [self enumerateObjectsUsingBlock: ^ (id object, size_t index, BOOL *stop) { tmp[index] = block(object, index); }]; |
︙ | ︙ | |||
588 589 590 591 592 593 594 | } - (OFArray*)filteredArrayUsingBlock: (of_array_filter_block_t)block { OFArray *ret; size_t count = [self count]; id *tmp = [self allocMemoryForNItems: count | | | 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 | } - (OFArray*)filteredArrayUsingBlock: (of_array_filter_block_t)block { OFArray *ret; size_t count = [self count]; id *tmp = [self allocMemoryForNItems: count ofSize: sizeof(id)]; @try { __block size_t i = 0; [self enumerateObjectsUsingBlock: ^ (id object, size_t index, BOOL *stop) { if (block(object, index)) |
︙ | ︙ |