-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Exp] Add GetMaxDepth #11970
[Exp] Add GetMaxDepth #11970
Conversation
return (*std::max_element( | ||
mSourceExpressions.begin(), | ||
mSourceExpressions.end(), | ||
[](const auto& rV1, const auto& rV2) { | ||
return rV1->GetMaxDepth() < rV2->GetMaxDepth(); | ||
}))->GetMaxDepth() + 1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a lot of repeated depth calculations. It might be worth to consider adding a depth member variable that gets computed at construction time (provided that child Expression
s are immutable), instead of always recomputing every depth for each child over and over again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but I don't see it getting called several times. [At the moment, it will only be called when the future Collapse
is called, but that happens when we Collapse
at the end. There is no point in Collapsing
every time]. I would say, we can move it to a member variable if this gets out of hand.
In any case, I simpliifed the recursions, so there are no redundant recursive calculations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a warning as well for future reference.
@matekelemen I have addressed your comments. Could you have a look? |
📝 Description
This PR adds
Expression::GetMaxDepth
to compute the maximum depth of the lazy expression tree structure.🆕 Changelog