Differences From Artifact [9e27844090]:
- File src/OFURL.m — part of check-in [8892ae9fcc] at 2012-07-12 01:28:46 on branch trunk — Don't access isa directly. (user: js, size: 11274) [annotate] [blame] [check-ins using]
To Artifact [4eed3ec6f3]:
- File
src/OFURL.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: 11239) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
20 21 22 23 24 25 26 | #include <string.h> #include <assert.h> #import "OFURL.h" #import "OFString.h" #import "OFArray.h" #import "OFXMLElement.h" | < > | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #include <string.h> #include <assert.h> #import "OFURL.h" #import "OFString.h" #import "OFArray.h" #import "OFXMLElement.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfMemoryException.h" #import "autorelease.h" #import "macros.h" static OF_INLINE OFString* resolve_relative_path(OFString *path) { void *pool = objc_autoreleasePoolPush(); OFMutableArray *array; OFString *ret; BOOL done = NO; array = [[[path componentsSeparatedByString: @"/"] mutableCopy] autorelease]; |
︙ | ︙ | |||
68 69 70 71 72 73 74 | break; } } } ret = [[array componentsJoinedByString: @"/"] retain]; | | | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | break; } } } ret = [[array componentsJoinedByString: @"/"] retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @implementation OFURL + URLWithString: (OFString*)string { |
︙ | ︙ | |||
144 145 146 147 148 149 150 | user = [[OFString alloc] initWithUTF8String: UTF8String]; UTF8String = tmp2; } if ((tmp2 = strchr(UTF8String, ':')) != NULL) { | | | | | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | user = [[OFString alloc] initWithUTF8String: UTF8String]; UTF8String = tmp2; } if ((tmp2 = strchr(UTF8String, ':')) != NULL) { void *pool; OFString *portString; *tmp2 = '\0'; tmp2++; host = [[OFString alloc] initWithUTF8String: UTF8String]; pool = objc_autoreleasePoolPush(); portString = [OFString stringWithUTF8String: tmp2]; if ([portString decimalValue] > 65535) @throw [OFInvalidFormatException exceptionWithClass: [self class]]; port = [portString decimalValue]; objc_autoreleasePoolPop(pool); } else { host = [[OFString alloc] initWithUTF8String: UTF8String]; if ([scheme isEqual: @"http"]) port = 80; else if ([scheme isEqual: @"https"]) |
︙ | ︙ | |||
258 259 260 261 262 263 264 | initWithUTF8String: tmp + 1]; } if (*UTF8String == '/') path = [[OFString alloc] initWithUTF8String: UTF8String]; else { | | | | | | | 258 259 260 261 262 263 264 265 266 267 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 306 307 308 309 310 311 312 313 | initWithUTF8String: tmp + 1]; } if (*UTF8String == '/') path = [[OFString alloc] initWithUTF8String: UTF8String]; else { void *pool; OFString *s; pool = objc_autoreleasePoolPush(); if ([URL->path hasSuffix: @"/"]) s = [OFString stringWithFormat: @"%@%s", URL->path, UTF8String]; else s = [OFString stringWithFormat: @"%@/../%s", URL->path, UTF8String]; path = [resolve_relative_path(s) copy]; objc_autoreleasePoolPop(pool); } } @catch (id e) { [self release]; @throw e; } @finally { free(UTF8String2); } return self; } - initWithSerialization: (OFXMLElement*)element { @try { void *pool = objc_autoreleasePoolPush(); if (![[element name] isEqual: [self className]] || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exceptionWithClass: [self class] selector: _cmd]; self = [self initWithString: [element stringValue]]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
550 551 552 553 554 555 556 | - (OFString*)description { return [self string]; } - (OFXMLElement*)XMLElementBySerializing { | | | | | | 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 | - (OFString*)description { return [self string]; } - (OFXMLElement*)XMLElementBySerializing { void *pool = objc_autoreleasePoolPush(); OFXMLElement *element; element = [OFXMLElement elementWithName: [self className] namespace: OF_SERIALIZATION_NS stringValue: [self string]]; [element retain]; objc_autoreleasePoolPop(pool); return [element autorelease]; } @end |