Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -768,10 +768,13 @@ } - (size_t)length { /* FIXME: Maybe cache this in an ivar? */ + + if (![self isUTF8]) + return length; return of_string_position_to_index(string, length); } - (size_t)cStringLength Index: src/OFXMLParser.m ================================================================== --- src/OFXMLParser.m +++ src/OFXMLParser.m @@ -48,41 +48,20 @@ withString: @"\n"]; [cache replaceOccurrencesOfString: @"\r" withString: @"\n"]; if (cut > 0) { - /* - * We need to create a mutable copy in order to detect possible - * UTF-8, as we never checked for UTF-8 when appending to the - * cache for performance reasons. - */ - OFMutableString *ret = [[cache mutableCopy] autorelease]; - size_t length; - - length = [ret length]; - [ret deleteCharactersFromIndex: length - cut - toIndex: length]; - - if (unescape) - return [ret stringByXMLUnescapingWithDelegate: - delegate]; - - /* - * Class swizzle the string to be immutable. We pass it as - * OFString*, so it can't be modified anyway. But not swizzling - * it would create a real copy each time -[copy] is called. - */ - ret->isa = [OFString class]; - - return ret; - } else { - if (unescape) - return [cache stringByXMLUnescapingWithDelegate: - delegate]; - else - return [[cache copy] autorelease]; - } + size_t length = [cache length]; + + [cache deleteCharactersFromIndex: length - cut + toIndex: length]; + } + + if (unescape) + return [cache stringByXMLUnescapingWithDelegate: delegate]; + else + return [[cache copy] autorelease]; } static OFString* namespace_for_prefix(OFString *prefix, OFArray *namespaces) {