Index: src/OFXMLElement.m ================================================================== --- src/OFXMLElement.m +++ src/OFXMLElement.m @@ -21,10 +21,11 @@ #import "OFXMLElement.h" #import "OFString.h" #import "OFArray.h" #import "OFDictionary.h" +#import "OFDataArray.h" #import "OFXMLAttribute.h" #import "OFXMLParser.h" #import "OFXMLElementBuilder.h" #import "OFAutoreleasePool.h" @@ -453,11 +454,11 @@ OFAutoreleasePool *pool, *pool2; char *cString; size_t length, i, j, attributesCount; OFString *prefix, *parentPrefix; OFXMLAttribute **attributesCArray; - OFString *ret, *tmp; + OFString *ret; OFMutableDictionary *allNamespaces; OFString *defaultNS; if (characters != nil) return [characters stringByXMLEscaping]; @@ -464,12 +465,10 @@ if (CDATA != nil) return [OFString stringWithFormat: @"", CDATA]; if (comment != nil) { - OFString *ret; - if (indentation > 0 && level > 0) { char *whitespaces = [self allocMemoryWithSize: (level * indentation) + 1]; memset(whitespaces, ' ', level * indentation); whitespaces[level * indentation] = 0; @@ -569,11 +568,12 @@ pool2 = [[OFAutoreleasePool alloc] init]; for (j = 0; j < attributesCount; j++) { OFString *attributeName = [attributesCArray[j] name]; OFString *attributePrefix = nil; - tmp = [[attributesCArray[j] stringValue] stringByXMLEscaping]; + OFString *tmp = + [[attributesCArray[j] stringValue] stringByXMLEscaping]; if ([attributesCArray[j] namespace] != nil && (attributePrefix = [allNamespaces objectForKey: [attributesCArray[j] namespace]]) == nil) @throw [OFUnboundNamespaceException @@ -614,17 +614,13 @@ /* Childen */ if (children != nil) { OFXMLElement **childrenCArray = [children cArray]; size_t childrenCount = [children count]; - IMP append; - SEL appendSel = @selector(appendCStringWithoutUTF8Checking:); + OFDataArray *tmp = [OFDataArray dataArray]; BOOL indent; - tmp = [OFMutableString string]; - append = [tmp methodForSelector: appendSel]; - if (indentation > 0) { indent = YES; for (j = 0; j < childrenCount; j++) { if (childrenCArray[j]->characters != nil || @@ -635,25 +631,28 @@ } } else indent = NO; for (j = 0; j < childrenCount; j++) { + OFString *child; + if (indent) - append(tmp, appendSel, "\n"); + [tmp addItem: "\n"]; - append(tmp, appendSel, - [[childrenCArray[j] + child = [childrenCArray[j] _XMLStringWithParent: self indentation: (indent ? indentation : 0) - level: level + 1] - cString]); + level: level + 1]; + + [tmp addNItems: [child cStringLength] + fromCArray: [child cString]]; } if (indent) - append(tmp, appendSel, "\n"); + [tmp addItem: "\n"]; - length += [tmp cStringLength] + [name cStringLength] + 2 + + length += [tmp count] + [name cStringLength] + 2 + (indent ? level * indentation : 0); @try { cString = [self resizeMemory: cString toSize: length]; } @catch (id e) { @@ -661,12 +660,12 @@ @throw e; } cString[i++] = '>'; - memcpy(cString + i, [tmp cString], [tmp cStringLength]); - i += [tmp cStringLength]; + memcpy(cString + i, [tmp cArray], [tmp count]); + i += [tmp count]; if (indent) { memset(cString + i, ' ', level * indentation); i += level * indentation; }