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

Adds non allocating alternatives to ZON parse functions #22916

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

MasonRemaley
Copy link
Contributor

Adds the following functions to std.zon.parse:

  • fromSliceFlat
  • fromZoirFlat
  • fromZoirNodeFlat

These are identical to the existing functions with "flat" stripped from the name, but they assert at compile time that the result type doesn't contain a pointer and therefore doesn't need to be freed. As such, the latter two functions do not require an allocator as an argument. (fromSlice still does as it needs to allocate the Ast and Zoir.)

I'm open to alternative suggestions for the names. I think "flat" as in "flat in memory" is pretty reasonable, though it could be misinterpreted as to do with nesting. I would have simply named them noAlloc, but this is confusing since fromSliceFlat does in fact create (temporary) allocations.

Replaces #22835, CC @NicoElbers (thanks for the reminder that I wanted to do this!)

@alexrp alexrp added this to the 0.14.0 milestone Feb 16, 2025
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.

2 participants