Repository: flex-asjs Updated Branches: refs/heads/develop 572b371ed -> 4159881e9
Lazy initialize _attributes array. Observed reduction of another ~10% of memory usage. Total memory usage appears to be less than half of what it was originally. Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/4159881e Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/4159881e Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/4159881e Branch: refs/heads/develop Commit: 4159881e95235d6ef698d5a931af1ddbeac6191a Parents: 572b371 Author: Harbs <[email protected]> Authored: Tue Sep 19 08:50:04 2017 +0300 Committer: Harbs <[email protected]> Committed: Tue Sep 19 08:50:04 2017 +0300 ---------------------------------------------------------------------- frameworks/projects/XML/src/main/flex/XML.as | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4159881e/frameworks/projects/XML/src/main/flex/XML.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/XML/src/main/flex/XML.as b/frameworks/projects/XML/src/main/flex/XML.as index 4fd596b..1c8946e 100644 --- a/frameworks/projects/XML/src/main/flex/XML.as +++ b/frameworks/projects/XML/src/main/flex/XML.as @@ -421,7 +421,7 @@ package } private var _children:Array; - private var _attributes:Array = []; + private var _attributes:Array; private var _processingInstructions:Array; private var _parent:XML; private var _value:String; @@ -462,13 +462,7 @@ package assertType(child,XML,"Type must be XML"); child.setParent(this); if(child.nodeKind() =="attribute") - { - if(!_attributes) - _attributes = []; - - _attributes.push(child); - - } + getAttributes().push(child); else getChildren().push(child); @@ -482,6 +476,14 @@ package return _children; } + private function getAttributes():Array + { + if(!_attributes) + _attributes = []; + + return _attributes; + } + /** * Adds a namespace to the set of in-scope namespaces for the XML object. * @@ -1903,8 +1905,8 @@ package public function setAttribute(attr:*,value:String):String { var i:int; - if(!_attributes) - _attributes = []; + //make sure _attributes is not null + getAttributes(); if(attr is XML) {
