[dasher: 16/27] Optimize DasherModel::CheckForNewRoot: the only child to check is known already!



commit 1474968b77306226b9e4312aebf1577842618b45
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date:   Sat Aug 14 20:16:48 2010 +0100

    Optimize DasherModel::CheckForNewRoot: the only child to check is known already!

 Src/DasherCore/DasherModel.cpp |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)
---
diff --git a/Src/DasherCore/DasherModel.cpp b/Src/DasherCore/DasherModel.cpp
index 15384dd..2ee0f95 100644
--- a/Src/DasherCore/DasherModel.cpp
+++ b/Src/DasherCore/DasherModel.cpp
@@ -599,24 +599,23 @@ bool CDasherModel::CheckForNewRoot(CDasherView *pView) {
   CDasherNode *pOldNode = Get_node_under_crosshair();
 #endif
 
-  CDasherNode *root(m_Root);
-
   if(!(m_Root->GetFlag(NF_SUPER))) {
+    CDasherNode *root(m_Root);    
     Reparent_root();
     return(m_Root != root);
   }
 
   CDasherNode *pNewRoot = NULL;
-
-  for (CDasherNode::ChildMap::const_iterator it = m_Root->GetChildren().begin(); it != m_Root->GetChildren().end(); it++) {
-    if ((*it)->GetFlag(NF_SUPER)) {
-      //at most one child should have NF_SUPER set...
-      DASHER_ASSERT(pNewRoot == NULL);
-      pNewRoot = *it;
-#ifndef DEBUG
-      break;
-#endif
+  if (m_Root->onlyChildRendered) {
+#ifdef DEBUG
+    //if only one child was rendered, no other child covers the screen -
+    // as no other child was onscreen at all!
+    for (CDasherNode::ChildMap::const_iterator it = m_Root->GetChildren().begin(); it != m_Root->GetChildren().end(); it++) {
+      DASHER_ASSERT(*it == m_Root->onlyChildRendered || !(*it)->GetFlag(NF_SUPER));
     }
+#endif
+    if (m_Root->onlyChildRendered->GetFlag(NF_SUPER))
+      pNewRoot = m_Root->onlyChildRendered;
   }
   ////GAME MODE TEMP - only change the root if it is on the game path/////////
   if (pNewRoot && (!m_bGameMode || pNewRoot->GetFlag(NF_GAME))) {



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