@@ -231,11 +231,11 @@ #ifdef OF_HAVE_UNICODE_TABLES - (void)of_convertWithWordStartTable: (const of_unichar_t *const [])startTable wordMiddleTable: (const of_unichar_t *const [])middleTable wordStartTableSize: (size_t)startTableSize - wordMiddleTableSize: (size_t)middleTableSize OF_DIRECT + wordMiddleTableSize: (size_t)middleTableSize { void *pool = objc_autoreleasePoolPush(); const of_unichar_t *characters = self.characters; size_t length = self.length; bool isStart = true; @@ -252,22 +252,21 @@ table = middleTable; tableSize = middleTableSize; } if (c >> 8 < tableSize && table[c >> 8][c & 0xFF]) - [self setCharacter: table[c >> 8][c & 0xFF] - atIndex: i]; + [self setCharacter: table[c >> 8][c & 0xFF] atIndex: i]; isStart = of_ascii_isspace(c); } objc_autoreleasePoolPop(pool); } #else -- (void)of_convertWithWordStartFunction: (char (*)(char))startFunction - wordMiddleFunction: (char (*)(char))middleFunction - OF_DIRECT +static void +convert(OFMutableString *self, char (*startFunction)(char), + char (*middleFunction)(char)) { void *pool = objc_autoreleasePoolPush(); const of_unichar_t *characters = self.characters; size_t length = self.length; bool isStart = true; @@ -276,93 +275,75 @@ char (*function)(char) = (isStart ? startFunction : middleFunction); of_unichar_t c = characters[i]; if (c <= 0x7F) - [self setCharacter: (int)function(c) - atIndex: i]; + [self setCharacter: (int)function(c) atIndex: i]; isStart = of_ascii_isspace(c); } objc_autoreleasePoolPop(pool); } #endif -- (void)setCharacter: (of_unichar_t)character - atIndex: (size_t)idx +- (void)setCharacter: (of_unichar_t)character atIndex: (size_t)idx { void *pool = objc_autoreleasePoolPush(); - OFString *string; - - string = [OFString stringWithCharacters: &character - length: 1]; - - [self replaceCharactersInRange: of_range(idx, 1) - withString: string]; - + OFString *string = + [OFString stringWithCharacters: &character length: 1]; + [self replaceCharactersInRange: of_range(idx, 1) withString: string]; objc_autoreleasePoolPop(pool); } - (void)appendString: (OFString *)string { - [self insertString: string - atIndex: self.length]; + [self insertString: string atIndex: self.length]; } - (void)appendCharacters: (const of_unichar_t *)characters length: (size_t)length { void *pool = objc_autoreleasePoolPush(); - [self appendString: [OFString stringWithCharacters: characters length: length]]; - objc_autoreleasePoolPop(pool); } - (void)appendUTF8String: (const char *)UTF8String { void *pool = objc_autoreleasePoolPush(); - [self appendString: [OFString stringWithUTF8String: UTF8String]]; - objc_autoreleasePoolPop(pool); } - (void)appendUTF8String: (const char *)UTF8String length: (size_t)UTF8StringLength { void *pool = objc_autoreleasePoolPush(); - [self appendString: [OFString stringWithUTF8String: UTF8String length: UTF8StringLength]]; - objc_autoreleasePoolPop(pool); } - (void)appendCString: (const char *)cString encoding: (of_string_encoding_t)encoding { void *pool = objc_autoreleasePoolPush(); - [self appendString: [OFString stringWithCString: cString encoding: encoding]]; - objc_autoreleasePoolPop(pool); } - (void)appendCString: (const char *)cString encoding: (of_string_encoding_t)encoding length: (size_t)cStringLength { void *pool = objc_autoreleasePoolPush(); - [self appendString: [OFString stringWithCString: cString encoding: encoding length: cStringLength]]; - objc_autoreleasePoolPop(pool); } - (void)appendFormat: (OFConstantString *)format, ... { @@ -372,12 +353,11 @@ [self appendFormat: format arguments: arguments]; va_end(arguments); } -- (void)appendFormat: (OFConstantString *)format - arguments: (va_list)arguments +- (void)appendFormat: (OFConstantString *)format arguments: (va_list)arguments { char *UTF8String; int UTF8StringLength; if (format == nil) @@ -386,33 +366,29 @@ if ((UTF8StringLength = of_vasprintf(&UTF8String, format.UTF8String, arguments)) == -1) @throw [OFInvalidFormatException exception]; @try { - [self appendUTF8String: UTF8String - length: UTF8StringLength]; + [self appendUTF8String: UTF8String length: UTF8StringLength]; } @finally { free(UTF8String); } } - (void)prependString: (OFString *)string { - [self insertString: string - atIndex: 0]; + [self insertString: string atIndex: 0]; } - (void)reverse { size_t i, j, length = self.length; for (i = 0, j = length - 1; i < length / 2; i++, j--) { of_unichar_t tmp = [self characterAtIndex: j]; - [self setCharacter: [self characterAtIndex: i] - atIndex: j]; - [self setCharacter: tmp - atIndex: i]; + [self setCharacter: [self characterAtIndex: i] atIndex: j]; + [self setCharacter: tmp atIndex: i]; } } #ifdef OF_HAVE_UNICODE_TABLES - (void)uppercase @@ -439,38 +415,32 @@ wordMiddleTableSize: OF_UNICODE_LOWERCASE_TABLE_SIZE]; } #else - (void)uppercase { - [self of_convertWithWordStartFunction: of_ascii_toupper - wordMiddleFunction: of_ascii_toupper]; + convert(self, of_ascii_toupper, of_ascii_toupper); } - (void)lowercase { - [self of_convertWithWordStartFunction: of_ascii_tolower - wordMiddleFunction: of_ascii_tolower]; + convert(self, of_ascii_tolower, of_ascii_tolower); } - (void)capitalize { - [self of_convertWithWordStartFunction: of_ascii_toupper - wordMiddleFunction: of_ascii_tolower]; + convert(self, of_ascii_toupper, of_ascii_tolower); } #endif -- (void)insertString: (OFString *)string - atIndex: (size_t)idx +- (void)insertString: (OFString *)string atIndex: (size_t)idx { - [self replaceCharactersInRange: of_range(idx, 0) - withString: string]; + [self replaceCharactersInRange: of_range(idx, 0) withString: string]; } - (void)deleteCharactersInRange: (of_range_t)range { - [self replaceCharactersInRange: range - withString: @""]; + [self replaceCharactersInRange: range withString: @""]; } - (void)replaceCharactersInRange: (of_range_t)range withString: (OFString *)replacement {