浏览代码

huge speedup in neko xml parsing when having many childs (close #1779)

Nicolas Cannasse 12 年之前
父节点
当前提交
c497db3ab1
共有 1 个文件被更改,包括 7 次插入4 次删除
  1. 7 4
      std/neko/_std/Xml.hx

+ 7 - 4
std/neko/_std/Xml.hx

@@ -54,6 +54,9 @@ enum XmlType {
 		x._children = new Array();
 		var parser = {
 			cur : x,
+			add : function(x:Dynamic) {
+				untyped __this__.cur._children.push(x);
+			},
 			xml : function(name,att) {
 				var x : Dynamic = new Xml();
 				x._parent = untyped __this__.cur;
@@ -69,7 +72,7 @@ enum XmlType {
 						__dollar__objset(att,f[i], new String(__dollar__objget(att,f[i]))) ;
 						i++;
 					}
-					__this__.cur.addChild(x);
+					__this__.add(x);
 					__this__.cur = x;
 				}
 			},
@@ -78,14 +81,14 @@ enum XmlType {
 				x._parent = untyped __this__.cur;
 				x.nodeType = Xml.CData;
 				x._nodeValue = new String(text);
-				untyped __this__.cur.addChild(x);
+				untyped __this__.add(x);
 			},
 			pcdata : function(text) {
 				var x : Dynamic = new Xml();
 				x._parent = untyped __this__.cur;
 				x.nodeType = Xml.PCData;
 				x._nodeValue = new String(text);
-				untyped __this__.cur.addChild(x);
+				untyped __this__.add(x);
 			},
 			comment : function(text) {
 				var x : Dynamic = new Xml();
@@ -99,7 +102,7 @@ enum XmlType {
 					text = new String(text);
 				}
 				x._nodeValue = text;
-				untyped __this__.cur.addChild(x);
+				untyped __this__.add(x);
 			},
 			doctype : function(text) {
 				var x : Dynamic = new Xml();