mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-18 05:11:41 +00:00
Merge with kaetemi-optimize
This commit is contained in:
commit
87520b2909
2 changed files with 29 additions and 0 deletions
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include "cdb.h"
|
||||
|
||||
#define NL_CDB_OPTIMIZE_PREDICT 1
|
||||
|
||||
namespace NLMISC{
|
||||
|
||||
/**
|
||||
|
@ -247,6 +249,10 @@ protected:
|
|||
|
||||
/// called by clear
|
||||
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" );
|
||||
_NodesByName.push_back( node );
|
||||
_Sorted = false;
|
||||
#if NL_CDB_OPTIMIZE_PREDICT
|
||||
_PredictNode = node;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // attachChild //
|
||||
|
@ -799,6 +802,18 @@ public:
|
|||
//-----------------------------------------------
|
||||
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)
|
||||
{
|
||||
_Sorted = true;
|
||||
|
@ -812,7 +827,15 @@ ICDBNode *CCDBNodeBranch::find(const std::string &nodeName)
|
|||
else
|
||||
{
|
||||
if (*(*it)->getName() == nodeName)
|
||||
{
|
||||
#if NL_CDB_OPTIMIZE_PREDICT
|
||||
ICDBNode *node = *it;
|
||||
_PredictNode = node;
|
||||
return node;
|
||||
#else
|
||||
return *it;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue