Skip to content
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

Make parent() return a Node #129

Merged
merged 2 commits into from
Aug 20, 2024
Merged

Conversation

fhackett
Copy link
Contributor

@fhackett fhackett commented Aug 5, 2024

Based on a recent discussion that was left out of scope of #128, there was an idea to make ->parent() return a Node rather than require callers to use shared_from_this (or intrusive_ptr_from_this now).

This PR makes that change. It:

  • changes parent() to return Node
  • adds parent_unsafe() that keeps old behavior if you don't want refcounting overheads and you know your borrow is safe

Point of discussion: what do we do with original calls to parent? Do all those calls in YAML change type, or do we make them parent_unsafe? I'm told it might have performance implications. So far, I only made ->parent()->intrusive_ptr_from_this() into ->parent() and otherwise went the unsafe route, but there's plenty of room for "don't care keep it simple" in other cases.

There's also a quick fix here for the test cases breaking in dependent projects, since this whole conversation is part of updating rego-cpp's dependencies. If this takes too long I can split that out. Moved to another PR

@matajoh matajoh merged commit 7ddc757 into microsoft:main Aug 20, 2024
21 checks passed
@fhackett fhackett deleted the fhackett-parent-api branch August 21, 2024 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants