graphql-js icon indicating copy to clipboard operation
graphql-js copied to clipboard

polish: use closure instead of CollectFieldsContext

Open yaacovCR opened this issue 8 months ago • 4 comments

While working on #4360, I felt myself trying to reach for opportunity to remove the CollectFieldsContext type/object that I previously introduced; this is accomplished in this separate PR.

Benchmarking on my machine, this seems essentially no better and no worse in the performance realm. I am evaluating this in terms of readability, both in the local sense and in the overall algorithmic sense of better understanding the method and limit of how we are recursing.

Overall, I think it's a minor improvement.

yaacovCR avatar Mar 23 '25 11:03 yaacovCR

Hi @yaacovCR, I'm @github-actions bot happy to help you with this PR 👋

Supported commands

Please post this commands in separate comments and only one per comment:

  • @github-actions run-benchmark - Run benchmark comparing base and merge commits for this PR
  • @github-actions publish-pr-on-npm - Build package from this PR and publish it on NPM

github-actions[bot] avatar Mar 23 '25 11:03 github-actions[bot]

Note: this would probably be most helpfully reviewed by ignoring whitespace differences and possibly side-by-side comparison.

yaacovCR avatar Mar 23 '25 11:03 yaacovCR

Also subtracts about 50 lines of code, which is always good.

From my machine:

image

yaacovCR avatar Mar 23 '25 13:03 yaacovCR

Also subtracts about 50 lines of code, which is always good.

Mostly whitespace/formatting though, so your mileage may vary, but it helps make the code more readable for me.

yaacovCR avatar Mar 23 '25 13:03 yaacovCR