ObjFW  Check-in [4a080857a2]

Overview
Comment:OFXMLParser: Don't recreate "attributes" all the time.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 4a080857a2efee01e4434d79b3b5c6a03101e5c91de1bc254aebcb3d161a5b24
User & Date: js on 2012-03-16 17:32:00
Other Links: manifest | tags
Context
2012-03-17
14:26
Move definition of __BIGGEST_ALIGNMENT__ to macros.h. check-in: 2d4a63cfcb user: js tags: trunk
2012-03-16
17:32
OFXMLParser: Don't recreate "attributes" all the time. check-in: 4a080857a2 user: js tags: trunk
17:14
Fix memory wasting in OFBigDataArray. check-in: 36872c7a25 user: js tags: trunk
Changes

Modified src/OFXMLParser.m from [a8f0eceb0e] to [8f2d46a92b].

185
186
187
188
189
190
191

192
193
194
195
196
197
198
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199







+







	@try {
		OFAutoreleasePool *pool;
		OFMutableDictionary *dict;

		cache = [[OFBigDataArray alloc] init];
		previous = [[OFMutableArray alloc] init];
		namespaces = [[OFMutableArray alloc] init];
		attributes = [[OFMutableArray alloc] init];

		pool = [[OFAutoreleasePool alloc] init];
		dict = [OFMutableDictionary dictionaryWithKeysAndObjects:
		    @"xml", @"http://www.w3.org/XML/1998/namespace",
		    @"xmlns", @"http://www.w3.org/2000/xmlns/", nil];
		[namespaces addObject: dict];

722
723
724
725
726
727
728
729

730
731
732
733
734
735
736
737
738
723
724
725
726
727
728
729

730
731

732
733
734
735
736
737
738







-
+

-







	} else
		[previous addObject: name];

	[pool release];

	[name release];
	[prefix release];
	[attributes release];
	[attributes removeAllObjects];
	name = prefix = nil;
	attributes = nil;

	*last = *i + 1;
	state = (buffer[*i] == '/'
	    ? OF_XMLPARSER_EXPECT_CLOSE
	    : OF_XMLPARSER_OUTSIDE_TAG);
}

823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
823
824
825
826
827
828
829



830
831
832
833
834
835
836







-
-
-







	if (attributePrefix == nil && [attributeName isEqual: @"xmlns"])
		[[namespaces lastObject] setObject: attributeValue
					    forKey: @""];
	if ([attributePrefix isEqual: @"xmlns"])
		[[namespaces lastObject] setObject: attributeValue
					    forKey: attributeName];

	if (attributes == nil)
		attributes = [[OFMutableArray alloc] init];

	[attributes addObject:
	    [OFXMLAttribute attributeWithName: attributeName
				    namespace: attributePrefix
				  stringValue: attributeValue]];

	[pool release];