Leave trailing comments after handling a possible trailing comma#10445
Merged
nicolo-ribaudo merged 2 commits intobabel:masterfrom Sep 23, 2019
Merged
Leave trailing comments after handling a possible trailing comma#10445nicolo-ribaudo merged 2 commits intobabel:masterfrom
nicolo-ribaudo merged 2 commits intobabel:masterfrom
Conversation
Collaborator
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/11584/ |
JLHwung
reviewed
Sep 16, 2019
| node.trailingComments.push(leadingComment); | ||
| } | ||
| } | ||
| if (takeAllComments) this.state.leadingComments.length = 0; |
Contributor
There was a problem hiding this comment.
nit: this.state.leadingComments = [] is more idiomatic and should be marginally faster than this.state.leadingComments.length = 0 by saving calls to StoreICTrampoline.
The former is compiled to
-- </Users/jh/code/babel/packages/babel-parser/lib/index.js:6266:14> --
0x1fafdfb87845 545 48b8a92cd4eaa8090000 REX.W movq rax,0x9a8ead42ca9 ;; object: 0x09a8ead42ca9 <Map(PACKED_ELEMENTS)>
0x1fafdfb8784f 54f 498947ff REX.W movq [r15-0x1],rax
0x1fafdfb87853 553 498b9da0000000 REX.W movq rbx,[r13+0xa0] (root (empty_fixed_array))
0x1fafdfb8785a 55a 49895f07 REX.W movq [r15+0x7],rbx
0x1fafdfb8785e 55e 49895f0f REX.W movq [r15+0xf],rbx
0x1fafdfb87862 562 49c7471700000000 REX.W movq [r15+0x17],0x0
-- </Users/jh/code/babel/packages/babel-parser/lib/index.js:6266:37> --
0x1fafdfb8786a 56a 4d89b9cf000000 REX.W movq [r9+0xcf],r15
0x1fafdfb87871 571 48c7c30000fcff REX.W movq rbx,0xfffc0000
0x1fafdfb87878 578 4923d9 REX.W andq rbx,r9
0x1fafdfb8787b 57b f6430804 testb [rbx+0x8],0x4The latter is compiled to
-- </Users/jh/code/babel/packages/babel-parser/lib/index.js:6268:44> --
0x1fafde852e4e 44e 33c0 xorl rax,rax
0x1fafde852e50 450 498b8d280a0000 REX.W movq rcx,[r13+0xa28] (root (length_string))
0x1fafde852e57 457 48bf000000002b000000 REX.W movq rdi,0x2b00000000
0x1fafde852e61 461 488b75e0 REX.W movq rsi,[rbp-0x20]
-- Inlined Trampoline to StoreICTrampoline --
0x1fafde852e65 465 49ba40fb6c0001000000 REX.W movq r10,0x1006cfb40 (StoreICTrampoline)
0x1fafde852e6f 46f 41ffd2 call r10
0x1fafdfb877aa 4aa 4c8b4518 REX.W movq r8,[rbp+0x18]
0x1fafdfb877ae 4ae 48b8a92cd4eaa8090000 REX.W movq rax,0x9a8ead42ca9 ;; object: 0x09a8ead42ca9 <Map(PACKED_ELEMENTS)>
0x1fafdfb877b8 4b8 49bce990a15ea8090000 REX.W movq r12,0x9a85ea190e9 ;; object: 0x09a85ea190e9 <Map(HOLEY_ELEMENTS)>
0x1fafdfb877c2 4c2 49bbf994a15ea8090000 REX.W movq r11,0x9a85ea194f9 ;; object: 0x09a85ea194f9 <Map(HOLEY_ELEMENTS)>
Member
Author
There was a problem hiding this comment.
Oh I thought that resetting the length was faster because it doesn't create a new array. Will update 👍
JLHwung
approved these changes
Sep 16, 2019
Member
Author
|
@banga Could you please review this PR if you have time? 🙏 |
banga
approved these changes
Sep 22, 2019
This was referenced Oct 3, 2019
This was referenced Oct 22, 2019
This was referenced Nov 28, 2019
This was referenced Dec 5, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.