Differences From Artifact [3601f4b0dd]:
- File src/OFArray.m — part of check-in [96bbfb777c] at 2012-08-04 00:51:09 on branch trunk — Add -[OFArray arrayByRemovingObject:]. (user: js, size: 14562) [annotate] [blame] [check-ins using]
To Artifact [208e599910]:
- File
src/OFArray.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: 14502) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
19 20 21 22 23 24 25 | #include <stdarg.h> #import "OFArray.h" #import "OFArray_subarray.h" #import "OFArray_adjacent.h" #import "OFString.h" #import "OFXMLElement.h" | < > | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #include <stdarg.h> #import "OFArray.h" #import "OFArray_subarray.h" #import "OFArray_adjacent.h" #import "OFString.h" #import "OFXMLElement.h" #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" #import "OFNotImplementedException.h" #import "OFOutOfRangeException.h" #import "autorelease.h" #import "macros.h" static struct { Class isa; } placeholder; @interface OFArray_placeholder: OFArray |
︙ | ︙ | |||
356 357 358 359 360 361 362 | return [self componentsJoinedByString: separator usingSelector: @selector(description)]; } - (OFString*)componentsJoinedByString: (OFString*)separator usingSelector: (SEL)selector { | | | > | < | | | 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | return [self componentsJoinedByString: separator usingSelector: @selector(description)]; } - (OFString*)componentsJoinedByString: (OFString*)separator usingSelector: (SEL)selector { void *pool; OFMutableString *ret; id *objects; size_t i, count = [self count]; IMP append; if (count == 0) return @""; if (count == 1) return [[self firstObject] performSelector: selector]; ret = [OFMutableString string]; append = [ret methodForSelector: @selector(appendString:)]; pool = objc_autoreleasePoolPush(); objects = [self objects]; for (i = 0; i < count - 1; i++) { void *pool2 = objc_autoreleasePoolPush(); append(ret, @selector(appendString:), [objects[i] performSelector: selector]); append(ret, @selector(appendString:), separator); objc_autoreleasePoolPop(pool2); } append(ret, @selector(appendString:), [objects[i] performSelector: selector]); [ret makeImmutable]; objc_autoreleasePoolPop(pool); return ret; } - (BOOL)isEqual: (id)object { /* FIXME: Optimize (for example, buffer of 16 for each) */ |
︙ | ︙ | |||
440 441 442 443 444 445 446 | OF_HASH_FINALIZE(hash); return hash; } - (OFString*)description { | | | | < | < | > | < | | | | | < < > > | | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | OF_HASH_FINALIZE(hash); return hash; } - (OFString*)description { void *pool; OFMutableString *ret; if ([self count] == 0) return @"()"; pool = objc_autoreleasePoolPush(); ret = [[self componentsJoinedByString: @",\n"] mutableCopy]; @try { [ret prependString: @"(\n"]; [ret replaceOccurrencesOfString: @"\n" withString: @"\n\t"]; [ret appendString: @"\n)"]; } @catch (id e) { [ret release]; @throw e; } objc_autoreleasePoolPop(pool); [ret makeImmutable]; return [ret autorelease]; } - (OFXMLElement*)XMLElementBySerializing { void *pool = objc_autoreleasePoolPush(); OFXMLElement *element; id <OFSerialization> *objects = [self objects]; size_t i, count = [self count]; if ([self isKindOfClass: [OFMutableArray class]]) element = [OFXMLElement elementWithName: @"OFMutableArray" namespace: OF_SERIALIZATION_NS]; else element = [OFXMLElement elementWithName: @"OFArray" namespace: OF_SERIALIZATION_NS]; for (i = 0; i < count; i++) { void *pool2 = objc_autoreleasePoolPush(); [element addChild: [objects[i] XMLElementBySerializing]]; objc_autoreleasePoolPop(pool2); } [element retain]; objc_autoreleasePoolPop(pool); return [element autorelease]; } - (OFString*)JSONRepresentation { void *pool = objc_autoreleasePoolPush(); OFMutableString *JSON; JSON = [[self componentsJoinedByString: @"," usingSelector: @selector(JSONRepresentation)] mutableCopy]; [JSON prependString: @"["]; [JSON appendString: @"]"]; [JSON makeImmutable]; objc_autoreleasePoolPop(pool); return [JSON autorelease]; } - (void)makeObjectsPerformSelector: (SEL)selector { id *objects = [self objects]; size_t i, count = [self count]; |
︙ | ︙ |