apollographql / apollo-rs

Spec compliant GraphQL Tools in Rust.
Apache License 2.0
566 stars 43 forks source link

chore(compiler): make unused variable validation more efficient #887

Closed goto-bus-stop closed 1 month ago

goto-bus-stop commented 1 month ago

A small thing I was doing for #883 but we merged that early ;)

The validation used a hash map and two hash sets. We can do the exact same validation with only a hash map, by first putting all declared variables in the hash map, and removing variables as we see them used. Then at the end we only have unused variables in the map.