Differences From Artifact [b0a0f37ea8]:
- File
src/OFString_UTF8.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: 25451) [annotate] [blame] [check-ins using]
To Artifact [743848703f]:
- File src/OFString_UTF8.m — part of check-in [3659c87c63] at 2012-09-06 19:13:50 on branch trunk — Add -[OFString initWithUTF8String:freeWhenDone:]. (user: js, size: 26300) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
240 241 242 243 244 245 246 247 248 249 250 251 252 253 | } @catch (id e) { [self release]; @throw e; } return self; } - initWithString: (OFString*)string { self = [super init]; @try { s = &s_store; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 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 | } @catch (id e) { [self release]; @throw e; } return self; } - initWithUTF8StringNoCopy: (const char*)UTF8String freeWhenDone: (BOOL)freeWhenDone { self = [super init]; @try { size_t UTF8StringLength = strlen(UTF8String); if (freeWhenDone) s->freeWhenDone = (char*)UTF8String; if (UTF8StringLength >= 3 && !memcmp(UTF8String, "\xEF\xBB\xBF", 3)) { UTF8String += 3; UTF8StringLength -= 3; } s = &s_store; s->cString = (char*)UTF8String; s->cStringLength = UTF8StringLength; switch (of_string_check_utf8(UTF8String, UTF8StringLength, &s->length)) { case 1: s->UTF8 = YES; break; case -1: @throw [OFInvalidEncodingException exceptionWithClass: [self class]]; } } @catch (id e) { [self release]; @throw e; } return self; } - initWithString: (OFString*)string { self = [super init]; @try { s = &s_store; |
︙ | ︙ | |||
567 568 569 570 571 572 573 574 575 576 577 578 579 580 | } @catch (id e) { [self release]; @throw e; } return self; } - (const char*)UTF8String { return s->cString; } - (const char*)cStringWithEncoding: (of_string_encoding_t)encoding | > > > > > > > > | 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 | } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { if (s != NULL && s->freeWhenDone != NULL) free(s->freeWhenDone); [super dealloc]; } - (const char*)UTF8String { return s->cString; } - (const char*)cStringWithEncoding: (of_string_encoding_t)encoding |
︙ | ︙ |