Possible virtual buffer optimization

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Possible virtual buffer optimization

derek riemer
We have 
 bool VBufStorage_buffer_t::isDescendantNode(VBufStorage_fieldNode_t* parent, VBufStorage_fieldNode_t* descendant) {

I noticed that each node has a length in characters. Couldn't an optimization be written which compares lengths, and if the child's length is larger than the parent, we don't have to compare all the way up?  Also, if this property is true, does the perf benefit of putting this check in even matter? 
maybe like
bool VBufStorage_buffer_t::isDescendantNode(VBufStorage_fieldNode_t* parent, VBufStorage_fieldNode_t* descendant) {
nhAssert(parent);
nhAssert(descendant);
LOG_DEBUG(L"is node at "<<descendant<<L" a descendant of node at "<<parent);
if(descendant -> length > parent -> length) return false; //definitely not larger.
for(VBufStorage_fieldNode_t* tempNode=descendant->parent;tempNode!=NULL;tempNode=tempNode->parent) {
if(tempNode==parent) {
LOG_DEBUG(L"Node is a descendant");
return true;
}
}
LOG_DEBUG(L"Not a descendant");
return false;
}


--

Derek Riemer: Improving the world one byte at a time!

  • University of Colorado Boulder Department of computer science, 4th year undergraduate student.
  • Accessibility enthusiast.
  • Proud user of the NVDA screen reader.
  • Open source enthusiast.
  • Skier.

Personal website



------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
Nvda-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nvda-devel
Loading...