mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-05 23:09:04 +00:00
Add some basic prediction to CCDBNodeBranch::find
--HG-- branch : kaetemi-optimize
This commit is contained in:
parent
d278a2ce23
commit
53bebec880
2 changed files with 29 additions and 0 deletions
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
#include "cdb.h"
|
#include "cdb.h"
|
||||||
|
|
||||||
|
#define NL_CDB_OPTIMIZE_PREDICT 1
|
||||||
|
|
||||||
namespace NLMISC{
|
namespace NLMISC{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -247,6 +249,10 @@ protected:
|
||||||
|
|
||||||
/// called by clear
|
/// called by clear
|
||||||
void removeAllBranchObserver();
|
void removeAllBranchObserver();
|
||||||
|
|
||||||
|
#if NL_CDB_OPTIMIZE_PREDICT
|
||||||
|
CRefPtr<ICDBNode> _PredictNode;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,6 +232,9 @@ void CCDBNodeBranch::attachChild( ICDBNode * node, string nodeName )
|
||||||
//nldebug ( "CDB: Attaching node" );
|
//nldebug ( "CDB: Attaching node" );
|
||||||
_NodesByName.push_back( node );
|
_NodesByName.push_back( node );
|
||||||
_Sorted = false;
|
_Sorted = false;
|
||||||
|
#if NL_CDB_OPTIMIZE_PREDICT
|
||||||
|
_PredictNode = node;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} // attachChild //
|
} // attachChild //
|
||||||
|
@ -799,6 +802,18 @@ public:
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
ICDBNode *CCDBNodeBranch::find(const std::string &nodeName)
|
ICDBNode *CCDBNodeBranch::find(const std::string &nodeName)
|
||||||
{
|
{
|
||||||
|
#if NL_CDB_OPTIMIZE_PREDICT
|
||||||
|
ICDBNode *predictNode = _PredictNode;
|
||||||
|
if (predictNode)
|
||||||
|
{
|
||||||
|
if (predictNode->getParent() == this
|
||||||
|
&& *predictNode->getName() == nodeName)
|
||||||
|
{
|
||||||
|
return predictNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!_Sorted)
|
if (!_Sorted)
|
||||||
{
|
{
|
||||||
_Sorted = true;
|
_Sorted = true;
|
||||||
|
@ -812,7 +827,15 @@ ICDBNode *CCDBNodeBranch::find(const std::string &nodeName)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (*(*it)->getName() == nodeName)
|
if (*(*it)->getName() == nodeName)
|
||||||
|
{
|
||||||
|
#if NL_CDB_OPTIMIZE_PREDICT
|
||||||
|
ICDBNode *node = *it;
|
||||||
|
_PredictNode = node;
|
||||||
|
return node;
|
||||||
|
#else
|
||||||
return *it;
|
return *it;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue