perf: Reduce the use of temporary objects#16959
Conversation
| printJoin( | ||
| nodes: Array<t.Node> | undefined | null, | ||
| opts: PrintJoinOptions = {}, | ||
| statement?: boolean, | ||
| indent?: boolean, | ||
| separator?: PrintJoinOptions["separator"], | ||
| printTrailingSeparator?: boolean, | ||
| addNewlines?: PrintJoinOptions["addNewlines"], | ||
| iterator?: PrintJoinOptions["iterator"], | ||
| trailingCommentsLineOffset?: number, | ||
| ) { |
There was a problem hiding this comment.
Their order is similar to the frequency of use.
There was a problem hiding this comment.
There are quite a few boolean options here, maybe we can pack them into bit flags.
There was a problem hiding this comment.
I was originally working on bit flags, but then realized the code needed was pretty much the same either way.
I'll switch it over to bit flags and see if that makes it a bit cleaner. :)
There was a problem hiding this comment.
Seems a bit difficult since indent===null would make sense.
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/58329 |
JLHwung
left a comment
There was a problem hiding this comment.
I am all for changes in this PR. The temporary object style was prevailing before we migrated to TS since at that moment the IDE can't infer the parameter names.
Fixes #1, Fixes #2#16958 (review)
main
PR