Overview
Comment: | One malloc less when allocating a string. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
3005748a9d440acd4ee2e033f3354f24 |
User & Date: | js on 2012-03-16 14:01:29 |
Other Links: | manifest | tags |
Context
2012-03-16
| ||
17:14 | Fix memory wasting in OFBigDataArray. check-in: 36872c7a25 user: js tags: trunk | |
14:01 | One malloc less when allocating a string. check-in: 3005748a9d user: js tags: trunk | |
2012-03-15
| ||
11:29 | Greatly improve OFObject's memory handling and performance. check-in: 28170f5f65 user: js tags: trunk | |
Changes
Modified src/OFMutableString_UTF8.h from [593b73ce69] to [ddae683c1b].
︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | + + | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFMutableString.h" #import "OFString_UTF8.h" @interface OFMutableString_UTF8: OFMutableString { @public struct of_string_utf8_ivars *restrict s; struct of_string_utf8_ivars s_store; } @end |
Modified src/OFString_UTF8.h from [958573e473] to [b1a5c898cd].
︙ | |||
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | + + + + + + + + | */ #import "OFString.h" @interface OFString_UTF8: OFString { @public /* * A pointer to the actual data. * * Since constant strings don't have s_store, they have to malloc it on * the first access. Strings created at runtime just set the pointer to * &s_store. */ struct of_string_utf8_ivars { char *cString; size_t cStringLength; BOOL UTF8; size_t length; BOOL hashed; uint32_t hash; } *restrict s; struct of_string_utf8_ivars s_store; } @end |
Modified src/OFString_UTF8.m from [2df9fbd0df] to [2441b116ae].
︙ | |||
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; |
︙ |