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

Expr: remove redundant fields, add nrExprs #8970

Merged
merged 3 commits into from
Sep 25, 2023

Conversation

roberth
Copy link
Member

@roberth roberth commented Sep 12, 2023

Motivation

Minor things I've found while helping out a bit with #8778

  • Slim int and float exprs
  • Count how many AST nodes we load

Context

Priorities

Add 👍 to pull requests you find important.

@roberth roberth requested a review from edolstra as a code owner September 12, 2023 11:48
@Ericson2314
Copy link
Member

Is there a reason why we don't do the same thing for the other exprs, like ExprString?

@roberth
Copy link
Member Author

roberth commented Sep 12, 2023

ExprString

That one seemed to be in an optimum, although possibly a local one of course. It uses a bunch of std::move and it appears that the bytes are already shared.
Removing the std::string from the Expr would remove the thing that owns the bytes. Another solution is perhaps to make it leak those bytes and than refer to it only in the Value. This does not seem like an obvious win, and I'm only doing low hanging fruit in this PR.

The bools are ExprVar, so not much that can be done there.

ExprPath is like string but is subject to change anyway with SourcePath I think.

Didn't spot any other instances of such duplication.

@Ericson2314
Copy link
Member

Ah! I didn't realize the std::string owns what the Value points too. OK that makes perfect sense and makes clear rules for when the other field is needed.

This is redundant since definitions in C++ record are implicitly inline-ed.

Co-authored-by: Yingchi Long <i@lyc.dev>
@roberth roberth enabled auto-merge September 25, 2023 16:51
@roberth roberth merged commit b19bd4f into NixOS:master Sep 25, 2023
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.

4 participants