Differences From Artifact [7172dc591d]:
- File src/OFMutableString.m — part of check-in [2517f18272] at 2010-04-17 16:09:37 on branch trunk — Give the methods in OFNumber better names. (user: js, size: 10757) [annotate] [blame] [check-ins using]
To Artifact [920953956a]:
- File
src/OFMutableString.m
— part of check-in
[37db8f0fb3]
at
2010-04-17 22:27:17
on branch trunk
— New ivar naming convention.
ivars are now named like this: thisIsAnIVar. If an accessor exists for
the ivar, the ivar is named like the accessor. This is required for
@property to work. (user: js, size: 10749) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
37 38 39 40 41 42 43 | { of_unichar_t c; of_unichar_t *ustr; size_t ulen, nlen, clen; size_t i, j, d; char *nstr; | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | { of_unichar_t c; of_unichar_t *ustr; size_t ulen, nlen, clen; size_t i, j, d; char *nstr; if (!isUTF8) { assert(table_size >= 1); uint8_t *p = (uint8_t*)string + length; uint8_t t; while (--p >= (uint8_t*)string) if ((t = table[0][*p]) != 0) |
︙ | ︙ | |||
127 128 129 130 131 132 133 | [self freeMemory: string]; len = strlen(str); switch (of_string_check_utf8(str, len)) { case 0: | | | | | | | 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 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | [self freeMemory: string]; len = strlen(str); switch (of_string_check_utf8(str, len)) { case 0: isUTF8 = NO; break; case 1: isUTF8 = YES; break; case -1: string = NULL; length = 0; isUTF8 = NO; @throw [OFInvalidEncodingException newWithClass: isa]; } length = len; string = [self allocMemoryWithSize: length + 1]; memcpy(string, str, length + 1); } - (void)appendCString: (const char*)str { size_t strlength; strlength = strlen(str); switch (of_string_check_utf8(str, strlength)) { case 1: isUTF8 = YES; break; case -1: @throw [OFInvalidEncodingException newWithClass: isa]; } string = [self resizeMemory: string toSize: length + strlength + 1]; memcpy(string + length, str, strlength + 1); length += strlength; } - (void)appendCString: (const char*)str withLength: (size_t)len { if (len > strlen(str)) @throw [OFOutOfRangeException newWithClass: isa]; switch (of_string_check_utf8(str, len)) { case 1: isUTF8 = YES; break; case -1: @throw [OFInvalidEncodingException newWithClass: isa]; } string = [self resizeMemory: string toSize: length + len + 1]; |
︙ | ︙ | |||
262 263 264 265 266 267 268 | /* We reverse all bytes and restore UTF-8 later, if necessary */ for (i = 0, j = length - 1; i < len; i++, j--) { string[i] ^= string[j]; string[j] ^= string[i]; string[i] ^= string[j]; } | | | 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | /* We reverse all bytes and restore UTF-8 later, if necessary */ for (i = 0, j = length - 1; i < len; i++, j--) { string[i] ^= string[j]; string[j] ^= string[i]; string[i] ^= string[j]; } if (!isUTF8) { madvise(string, len, MADV_NORMAL); return; } for (i = 0; i < length; i++) { /* ASCII */ if (OF_LIKELY(!(string[i] & 0x80))) |
︙ | ︙ | |||
353 354 355 356 357 358 359 | [self _applyTable: of_unicode_lower_table withSize: OF_UNICODE_LOWER_TABLE_SIZE]; } - (void)removeCharactersFromIndex: (size_t)start toIndex: (size_t)end { | | | 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | [self _applyTable: of_unicode_lower_table withSize: OF_UNICODE_LOWER_TABLE_SIZE]; } - (void)removeCharactersFromIndex: (size_t)start toIndex: (size_t)end { if (isUTF8) { start = of_string_index_to_position(string, start, length); end = of_string_index_to_position(string, end, length); } if (start > end) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; |
︙ | ︙ |