Overview
Comment: | Use OFDataArray instead of OFMutableString in OFXMLElement. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
a2c6391204cc28968f3fa3aa4b0afb16 |
User & Date: | js on 2011-07-09 13:15:08 |
Other Links: | manifest | tags |
Context
2011-07-09
| ||
13:29 | OFString+XMLUnescaping: Get rid of -[appendCStringWithoutUTF8Checking:]. check-in: 898c2a781b user: js tags: trunk | |
13:15 | Use OFDataArray instead of OFMutableString in OFXMLElement. check-in: a2c6391204 user: js tags: trunk | |
12:04 | Optimize +[stringWithPath:]. check-in: 1c65e229e8 user: js tags: trunk | |
Changes
Modified src/OFXMLElement.m from [4fc586873f] to [62ec69347f].
︙ | ︙ | |||
19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #include <string.h> #include <assert.h> #import "OFXMLElement.h" #import "OFString.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFXMLAttribute.h" #import "OFXMLParser.h" #import "OFXMLElementBuilder.h" #import "OFAutoreleasePool.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" | > | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include <string.h> #include <assert.h> #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" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" |
︙ | ︙ | |||
451 452 453 454 455 456 457 | level: (size_t)level { OFAutoreleasePool *pool, *pool2; char *cString; size_t length, i, j, attributesCount; OFString *prefix, *parentPrefix; OFXMLAttribute **attributesCArray; | | < < | 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | level: (size_t)level { OFAutoreleasePool *pool, *pool2; char *cString; size_t length, i, j, attributesCount; OFString *prefix, *parentPrefix; OFXMLAttribute **attributesCArray; OFString *ret; OFMutableDictionary *allNamespaces; OFString *defaultNS; if (characters != nil) return [characters stringByXMLEscaping]; if (CDATA != nil) return [OFString stringWithFormat: @"<![CDATA[%@]]>", CDATA]; if (comment != nil) { if (indentation > 0 && level > 0) { char *whitespaces = [self allocMemoryWithSize: (level * indentation) + 1]; memset(whitespaces, ' ', level * indentation); whitespaces[level * indentation] = 0; @try { |
︙ | ︙ | |||
567 568 569 570 571 572 573 | attributesCArray = [attributes cArray]; attributesCount = [attributes count]; pool2 = [[OFAutoreleasePool alloc] init]; for (j = 0; j < attributesCount; j++) { OFString *attributeName = [attributesCArray[j] name]; OFString *attributePrefix = nil; | > | | 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 | attributesCArray = [attributes cArray]; attributesCount = [attributes count]; pool2 = [[OFAutoreleasePool alloc] init]; for (j = 0; j < attributesCount; j++) { OFString *attributeName = [attributesCArray[j] name]; OFString *attributePrefix = nil; OFString *tmp = [[attributesCArray[j] stringValue] stringByXMLEscaping]; if ([attributesCArray[j] namespace] != nil && (attributePrefix = [allNamespaces objectForKey: [attributesCArray[j] namespace]]) == nil) @throw [OFUnboundNamespaceException newWithClass: isa namespace: [attributesCArray[j] namespace]]; |
︙ | ︙ | |||
612 613 614 615 616 617 618 | [pool2 releaseObjects]; } /* Childen */ if (children != nil) { OFXMLElement **childrenCArray = [children cArray]; size_t childrenCount = [children count]; | | < < < < > > | < | | > > | | | | | | 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 | [pool2 releaseObjects]; } /* Childen */ if (children != nil) { OFXMLElement **childrenCArray = [children cArray]; size_t childrenCount = [children count]; OFDataArray *tmp = [OFDataArray dataArray]; BOOL indent; if (indentation > 0) { indent = YES; for (j = 0; j < childrenCount; j++) { if (childrenCArray[j]->characters != nil || childrenCArray[j]->CDATA != nil) { indent = NO; break; } } } else indent = NO; for (j = 0; j < childrenCount; j++) { OFString *child; if (indent) [tmp addItem: "\n"]; child = [childrenCArray[j] _XMLStringWithParent: self indentation: (indent ? indentation : 0) level: level + 1]; [tmp addNItems: [child cStringLength] fromCArray: [child cString]]; } if (indent) [tmp addItem: "\n"]; length += [tmp count] + [name cStringLength] + 2 + (indent ? level * indentation : 0); @try { cString = [self resizeMemory: cString toSize: length]; } @catch (id e) { [self freeMemory: cString]; @throw e; } cString[i++] = '>'; memcpy(cString + i, [tmp cArray], [tmp count]); i += [tmp count]; if (indent) { memset(cString + i, ' ', level * indentation); i += level * indentation; } cString[i++] = '<'; |
︙ | ︙ |