Differences From Artifact [2df9fbd0df]:
- File
src/OFString_UTF8.m
— part of check-in
[28170f5f65]
at
2012-03-15 11:29:24
on branch trunk
— Greatly improve OFObject's memory handling and performance.
A linked-list is put before each memory chunk allocated instead of
having an array of all memory chunks. This means only one malloc now
instead of one malloc and one realloc. This also means that when
checking reallocs and frees, it's no longer necessary to iterate through
all memory chunks, as the linked list also contains the owner, meaning
realloc and free are no longer O(n), but O(1) now.As allocating bigger chunks seems to be a little bit slower than smaller
chunks, it seems that this is slightly slower in benchmarks if only very small
chunks are allocated. However, measuring real world usage, it's a lot faster. (user: js, size: 24829) [annotate] [blame] [check-ins using]
To Artifact [2441b116ae]:
- File src/OFString_UTF8.m — part of check-in [3005748a9d] at 2012-03-16 14:01:29 on branch trunk — One malloc less when allocating a string. (user: js, size: 24423) [annotate] [blame] [check-ins using]
︙ | |||
60 61 62 63 64 65 66 | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | - + - | @implementation OFString_UTF8 - init { self = [super init]; @try { |
︙ | |||
89 90 91 92 93 94 95 | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | - + - | if (encoding == OF_STRING_ENCODING_UTF_8 && cStringLength >= 3 && !memcmp(cString, "\xEF\xBB\xBF", 3)) { cString += 3; cStringLength -= 3; } |
︙ | |||
210 211 212 213 214 215 216 | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | - + - | } - initWithString: (OFString*)string { self = [super init]; @try { |
︙ | |||
253 254 255 256 257 258 259 | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | - + - | } else if (length > 0 && *string == 0xFFFE0000) { swap = YES; string++; length--; } else if (byteOrder != OF_ENDIANESS_NATIVE) swap = YES; |
︙ | |||
336 337 338 339 340 341 342 | 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | - + - | } else if (length > 0 && *string == 0xFFFE) { swap = YES; string++; length--; } else if (byteOrder != OF_ENDIANESS_NATIVE) swap = YES; |
︙ | |||
439 440 441 442 443 444 445 | 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | - + - | int cStringLength; if (format == nil) @throw [OFInvalidArgumentException exceptionWithClass: isa selector: _cmd]; |
︙ | |||
484 485 486 487 488 489 490 | 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | - + - | self = [super init]; @try { OFString *component; size_t i, cStringLength; va_list argumentsCopy; |
︙ |