Author Topic: question on the GetDeepestMatchingPosition function  (Read 3974 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5370
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
question on the GetDeepestMatchingPosition function
« on: March 03, 2009, 03:34:16 pm »
This is a bit strange.

Code
inline unsigned int SearchTreeNode::GetDeepestMatchingPosition(BasicSearchTree* tree, const wxString& s,unsigned int StringStartDepth)

I carefully examined the code, I found that the above function will always be called with the parameter StringStartDepth==0.

The only existence of this call is in FindNode().

Code
bool BasicSearchTree::FindNode(const wxString& s, nSearchTreeNode nparent, SearchTreePoint* result)
{
        size_t top_depth = m_pNodes[nparent]->GetDepth();
       ......
        unsigned int newdepth = childnode->GetDeepestMatchingPosition(this,s,top_depth);
       ......
}

But all the FindNode() function was used like below( the second parameter is always 0 )

Code
FindNode(s, 0, &resultpos)

So, the root node's parent is itself. and its depth is surely zero.


Any comments?  Thanks.


If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.