🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Sep 16, 2019

Q                       A
Fixed Issues? Fixes #10432, fixes #9102
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: parser area: comments i: regression labels Sep 16, 2019
@babel-bot
Copy link
Collaborator

babel-bot commented Sep 16, 2019

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/11584/

node.trailingComments.push(leadingComment);
}
}
if (takeAllComments) this.state.leadingComments.length = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

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],0x4

The 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)>

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh I thought that resetting the length was faster because it doesn't create a new array. Will update 👍

@hzoo hzoo changed the title Leave trailing comments aftre handling a possible trailing comma Leave trailing comments after handling a possible trailing comma Sep 17, 2019
@nicolo-ribaudo
Copy link
Member Author

@banga Could you please review this PR if you have time? 🙏

@lock lock bot locked as resolved and limited conversation to collaborators Dec 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: comments i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser PR: Bug Fix 🐛 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

istanbul ignore next is ignored after upgrade @babel/core from 7.5.5 to 7.6.0 looks like leading comments wrong when var decls not ends with semi

4 participants