Return a pointer to a sub node with a given name
| 51 | |
| 52 | // Return a pointer to a sub node with a given name |
| 53 | ProfileNode* ProfileNode::findSubNode(const char* name) { |
| 54 | |
| 55 | // Try to find the node among the child nodes |
| 56 | ProfileNode* child = mChildNode; |
| 57 | while (child != nullptr) { |
| 58 | if (child->mName == name) { |
| 59 | return child; |
| 60 | } |
| 61 | child = child->mSiblingNode; |
| 62 | } |
| 63 | |
| 64 | // The nose has not been found. Therefore, we create it |
| 65 | // and add it to the profiler tree |
| 66 | ProfileNode* newNode = new ProfileNode(name, this); |
| 67 | newNode->mSiblingNode = mChildNode; |
| 68 | mChildNode = newNode; |
| 69 | |
| 70 | return newNode; |
| 71 | } |
| 72 | |
| 73 | // Called when we enter the block of code corresponding to this profile node |
| 74 | void ProfileNode::enterBlockOfCode() { |