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

cynic-parser: implement PartialEq for Type and Value #924

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

tomhoule
Copy link
Contributor

I am conflicted on whether this should be PartialEq or a method, but since there is only one useful way to compare {types,values}, I went with PartialEq, as well as Eq for types (Value has a Float variant).

I am conflicted on whether this should be PartialEq or a method, but since
there is only one useful way to compare {types,values}, I went with
PartialEq, as well as Eq for types (Value has a Float variant).
Copy link

netlify bot commented Apr 16, 2024

Deploy Preview for cynic-querygen-web canceled.

Name Link
🔨 Latest commit e9d9d05
🔍 Latest deploy log https://app.netlify.com/sites/cynic-querygen-web/deploys/661e2f5aa9fec400096ac3c0

(Value::Int(a), Value::Int(b)) => a == b,
(Value::Variable(a), Value::Variable(b)) => a == b,
(Value::Float(a), Value::Float(b)) => a == b,
(Value::String(a), Value::String(b)) => a == b,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was surprised to see no Value::BlockString variant in executable. Is it because the difference is less relevant there, or an omission?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of intentional, though now that you point it out I am not sure it makes sense.

When I added support for block string processing I noticed it was incredibly slow - like a good 20-30% of schema parsing was spent processing block strings. So I made the processing of them lazy for schema parsing. There's a lot less block strings (and the documents generally tend to be smaller) in executables so I didn't make that optimisation here.

But I might remove the BlockString variant from Value. The main thing I wanted to optimise was docstrings - there's so many use cases that do not need them, so taking significant time to always process them seemed silly. But Value is a lot more likely to be used (and also wouldn't expect as many of them as blockstrings).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good to know, that makes sense.

@obmarg obmarg merged commit 9de383b into obmarg:main Apr 16, 2024
6 checks passed
@tomhoule tomhoule deleted the type-and-value-partial-eq branch April 16, 2024 09:36
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