gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/trunk r11653: A better way of delaying chi


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11653: A better way of delaying childNodes construction.
Date: Thu, 26 Nov 2009 17:49:56 +0100
User-agent: Bazaar (1.16.1)

------------------------------------------------------------
revno: 11653 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Thu 2009-11-26 17:49:56 +0100
message:
  A better way of delaying childNodes construction.
modified:
  libcore/asobj/flash/xml/XMLDocument_as.cpp
  libcore/asobj/flash/xml/XMLNode_as.cpp
  libcore/asobj/flash/xml/XMLNode_as.h
=== modified file 'libcore/asobj/flash/xml/XMLDocument_as.cpp'
--- a/libcore/asobj/flash/xml/XMLDocument_as.cpp        2009-11-26 14:30:42 
+0000
+++ b/libcore/asobj/flash/xml/XMLDocument_as.cpp        2009-11-26 16:11:18 
+0000
@@ -498,7 +498,7 @@
             childNode->setAttribute(i->first, i->second);
         }
 
-        node->appendChild(childNode, false);
+        node->appendChild(childNode);
         if (*it == '/') ++it;
         else node = childNode;
 
@@ -562,7 +562,7 @@
     unescapeXML(content);
 
     childNode->nodeValueSet(content);
-    node->appendChild(childNode, false);
+    node->appendChild(childNode);
 
     //log_debug("appended text node: %s", content);
 }
@@ -599,7 +599,7 @@
     XMLNode_as* childNode = new XMLNode_as(_global);
     childNode->nodeValueSet(content);
     childNode->nodeTypeSet(Text);
-    node->appendChild(childNode, false);
+    node->appendChild(childNode);
     
 }
 

=== modified file 'libcore/asobj/flash/xml/XMLNode_as.cpp'
--- a/libcore/asobj/flash/xml/XMLNode_as.cpp    2009-11-26 15:02:01 +0000
+++ b/libcore/asobj/flash/xml/XMLNode_as.cpp    2009-11-26 16:11:18 +0000
@@ -141,9 +141,7 @@
 void
 XMLNode_as::updateChildNodes()
 {
-    if (!_childNodes) {
-        _childNodes = _global.createArray();
-    }
+    if (!_childNodes) return;
 
     // Clear array of all elements.
     _childNodes->set_member(NSV::PROP_LENGTH, 0.0);
@@ -169,6 +167,7 @@
 XMLNode_as::childNodes()
 {
     if (!_childNodes) {
+        _childNodes = _global.createArray();
         updateChildNodes();
     }
     return _childNodes;
@@ -213,12 +212,12 @@
 }
 
 void
-XMLNode_as::appendChild(XMLNode_as* node, bool update)
+XMLNode_as::appendChild(XMLNode_as* node)
 {
     assert(node);
     node->setParent(this);
     _children.push_back(node);
-    if (update) updateChildNodes();
+    updateChildNodes();
 }
 
 void

=== modified file 'libcore/asobj/flash/xml/XMLNode_as.h'
--- a/libcore/asobj/flash/xml/XMLNode_as.h      2009-11-26 14:30:42 +0000
+++ b/libcore/asobj/flash/xml/XMLNode_as.h      2009-11-26 16:11:18 +0000
@@ -141,21 +141,21 @@
     /// Append a child node to this XML object
     //
     /// The child node's parent is set to this object, the node is added to
-    /// this object's children, the _childNodes array may be updated.
+    /// this object's children.
+    //
+    /// The childNodes array will be updated if it exists.
     //
     /// @param node     The node to add as a child
-    /// @param update   Whether to update the array of childNodes. When XML
-    ///                 trees are automatically created, e.g. during parseXML,
-    ///                 there is no need to create or update the array on
-    ///                 each append. Omitting the update reduces CPU usage
-    ///                 and memory usage (creating the array means creating
-    ///                 a referenceable object).
-       void appendChild(XMLNode_as* node, bool update = true);
+       void appendChild(XMLNode_as* node);
 
     /// Remove a child node from this XML object
     //
     /// The child node's parent is set to 0, the node is removed from
-    /// this object's children, the _childNodes array is updated.
+    /// this object's children.
+    //
+    /// The childNodes array will be updated if it exists.
+    //
+    /// @param node     The node to remove.
     void removeChild(XMLNode_as* node);
 
     /// Get the parent XMLNode_as of this node. Can be 0.
@@ -174,7 +174,7 @@
     /// @param newnode
     ///     The node to insert, moving from its current tree
     ///
-    /// @param beforeWhich
+    /// @param pos
     ///     The node before which to insert the new one.
     ///     Must be a child of this XMLNode or the operation will fail.
     ///
@@ -242,7 +242,9 @@
 
     /// Reset the array of childNodes to match the actual children.
     //
-    /// Only called when the XML structure changes.
+    /// Only called when the XML structure changes, and only once the
+    /// childNodes array has been created. Before this point it is not
+    /// referenceable, so we don't need to do anything.
     void updateChildNodes();
 
     /// A non-trivial copy-constructor for cloning nodes.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]