Differences From Artifact [3687781c21]:
- File src/OFDataArray.m — part of check-in [8892ae9fcc] at 2012-07-12 01:28:46 on branch trunk — Don't access isa directly. (user: js, size: 12474) [annotate] [blame] [check-ins using]
To Artifact [aae2d470af]:
- File
src/OFDataArray.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: 12462) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
22 23 24 25 26 27 28 | #import "OFDataArray.h" #import "OFString.h" #import "OFFile.h" #import "OFURL.h" #import "OFHTTPRequest.h" #import "OFXMLElement.h" | < > | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #import "OFDataArray.h" #import "OFString.h" #import "OFFile.h" #import "OFURL.h" #import "OFHTTPRequest.h" #import "OFXMLElement.h" #import "OFHTTPRequestFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidEncodingException.h" #import "OFNotImplementedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "autorelease.h" #import "base64.h" #import "macros.h" /* References for static linking */ void _references_to_categories_of_OFDataArray(void) { _OFDataArray_Hashing_reference = 1; |
︙ | ︙ | |||
127 128 129 130 131 132 133 | } return self; } - initWithContentsOfURL: (OFURL*)URL { | | | | | | 127 128 129 130 131 132 133 134 135 136 137 138 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 164 165 166 167 | } return self; } - initWithContentsOfURL: (OFURL*)URL { void *pool; OFHTTPRequest *request; OFHTTPRequestResult *result; Class c; c = [self class]; [self release]; pool = objc_autoreleasePoolPush(); if ([[URL scheme] isEqual: @"file"]) { self = [[c alloc] initWithContentsOfFile: [URL path]]; objc_autoreleasePoolPop(pool); return self; } request = [OFHTTPRequest requestWithURL: URL]; result = [request perform]; if ([result statusCode] != 200) @throw [OFHTTPRequestFailedException exceptionWithClass: [request class] HTTPRequest: request result: result]; self = [[result data] retain]; objc_autoreleasePoolPop(pool); return self; } - initWithBase64EncodedString: (OFString*)string { self = [super init]; |
︙ | ︙ | |||
181 182 183 184 185 186 187 | - initWithSerialization: (OFXMLElement*)element { self = [super init]; itemSize = 1; @try { | | | | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | - initWithSerialization: (OFXMLElement*)element { self = [super init]; itemSize = 1; @try { void *pool = objc_autoreleasePoolPush(); OFString *stringValue; if (![[element name] isEqual: [self className]] || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exceptionWithClass: [self class] selector: _cmd]; stringValue = [element stringValue]; if (!of_base64_decode(self, [stringValue cStringWithEncoding: OF_STRING_ENCODING_ASCII], [stringValue cStringLengthWithEncoding: OF_STRING_ENCODING_ASCII])) @throw [OFInvalidEncodingException exceptionWithClass: [self class]]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
444 445 446 447 448 449 450 | } @finally { [file release]; } } - (OFXMLElement*)XMLElementBySerializing { | | | | | | | 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 | } @finally { [file release]; } } - (OFXMLElement*)XMLElementBySerializing { void *pool; OFXMLElement *element; if (itemSize != 1) @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; pool = objc_autoreleasePoolPush(); element = [OFXMLElement elementWithName: [self className] namespace: OF_SERIALIZATION_NS stringValue: of_base64_encode(data, count * itemSize)]; [element retain]; objc_autoreleasePoolPop(pool); return [element autorelease]; } @end @implementation OFBigDataArray - (void)addItem: (const void*)item { size_t newSize, lastPageByte; |
︙ | ︙ |