Skip to content

Commit

Permalink
refactor(atoms): Remove usage of js_word! to drop string-cache (#…
Browse files Browse the repository at this point in the history
…7976)

**Description:**

This PR is to prepare removal of `string-cache`. Actually, this PR does not remove it. Instead, this PR only removes direct usages of `js_word!`s, especially in patterns.



**Related issue:**

 - #4946.
  • Loading branch information
kdy1 authored Oct 8, 2023
1 parent 2da1037 commit 84cec87
Show file tree
Hide file tree
Showing 546 changed files with 7,369 additions and 9,485 deletions.
28 changes: 7 additions & 21 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ xtask = "run --package xtask --"
[build]

rustdocflags = ["--cfg", "docsrs"]
rustflags = ["-Z", "share-generics=y"]
rustflags = ["-Zshare-generics=y"]

[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "target-feature=+sse2", "-Z", "share-generics=y"]

[target.aarch64-apple-darwin]
rustflags = ["-Z", "share-generics=y"]
rustflags = ["-C", "target-feature=+sse2", "-Zshare-generics=y"]

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
rustflags = ["-Z", "share-generics=y"]
linker = "aarch64-linux-gnu-gcc"

[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-musl-gcc"
Expand All @@ -23,27 +19,17 @@ rustflags = [
"target-feature=-crt-static",
"-C",
"link-arg=-lgcc",
"-Z",
"share-generics=y",
"-Zshare-generics=y",
]

[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
rustflags = ["-Z", "share-generics=y"]
linker = "arm-linux-gnueabihf-gcc"

[target.aarch64-linux-android]
rustflags = ["-Z", "share-generics=y"]

[target.x86_64-pc-windows-msvc]
linker = "rust-lld"
rustflags = ["-C", "target-feature=+crt-static"]
rustflags = ["-C", "target-feature=+crt-static", "-Zshare-generics=y"]

[target.i686-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]

[target.aarch64-pc-windows-msvc]
linker = "rust-lld"
rustflags = ["-Z", "share-generics=y"]

[target.wasm32-unknown-unknown]
rustflags = ["-Z", "share-generics=y"]
linker = "rust-lld"
6 changes: 3 additions & 3 deletions bindings/binding_core_node/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,23 +279,23 @@ impl swc_core::bundler::Hook for Hook {

Ok(vec![
KeyValueProp {
key: PropName::Ident(Ident::new(js_word!("url"), span)),
key: PropName::Ident(Ident::new("url", span)),
value: Box::new(Expr::Lit(Lit::Str(Str {
span,
raw: None,
value: file_name.into(),
}))),
},
KeyValueProp {
key: PropName::Ident(Ident::new(js_word!("main"), span)),
key: PropName::Ident(Ident::new("main", span)),
value: Box::new(if module_record.is_entry {
Expr::Member(MemberExpr {
span,
obj: Box::new(Expr::MetaProp(MetaPropExpr {
span,
kind: MetaPropKind::ImportMeta,
})),
prop: MemberProp::Ident(Ident::new(js_word!("main"), span)),
prop: MemberProp::Ident(Ident::new("main", span)),
})
} else {
Expr::Lit(Lit::Bool(Bool { span, value: false }))
Expand Down
6 changes: 6 additions & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@ disallowed-names = [
"isize",
"usize",
]
ignore-interior-mutability = [
"bytes::Bytes",
"swc_atoms::Atom",
"swc_atoms::JsWord",
"swc_ecma_ast::Id",
]
msrv = "1.58"
type-complexity-threshold = 25000
16 changes: 8 additions & 8 deletions crates/jsdoc/tests/fixtures/abstracttag.debug
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
),
ctxt: #0,
},
value: Atom('' type=static),
value: "",
},
tags: [
TagItem {
Expand All @@ -42,7 +42,7 @@
),
ctxt: #0,
},
value: Atom('constructor' type=static),
value: "constructor",
},
tag: Class(
ClassTag {
Expand Down Expand Up @@ -82,7 +82,7 @@
),
ctxt: #0,
},
value: Atom('' type=static),
value: "",
},
tags: [
TagItem {
Expand All @@ -105,7 +105,7 @@
),
ctxt: #0,
},
value: Atom('abstract' type=static),
value: "abstract",
},
tag: Abstract(
AbstractTag {
Expand Down Expand Up @@ -143,7 +143,7 @@
),
ctxt: #0,
},
value: Atom('' type=static),
value: "",
},
tags: [
TagItem {
Expand All @@ -166,7 +166,7 @@
),
ctxt: #0,
},
value: Atom('constructor' type=static),
value: "constructor",
},
tag: Class(
ClassTag {
Expand Down Expand Up @@ -206,7 +206,7 @@
),
ctxt: #0,
},
value: Atom('' type=static),
value: "",
},
tags: [
TagItem {
Expand All @@ -229,7 +229,7 @@
),
ctxt: #0,
},
value: Atom('virtual' type=inline),
value: "virtual",
},
tag: Abstract(
AbstractTag {
Expand Down
42 changes: 21 additions & 21 deletions crates/jsdoc/tests/fixtures/accesstag.debug
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
),
ctxt: #0,
},
value: Atom('' type=static),
value: "",
},
tags: [
TagItem {
Expand All @@ -42,7 +42,7 @@
),
ctxt: #0,
},
value: Atom('constructor' type=static),
value: "constructor",
},
tag: Class(
ClassTag {
Expand Down Expand Up @@ -82,7 +82,7 @@
),
ctxt: #0,
},
value: Atom('' type=static),
value: "",
},
tags: [
TagItem {
Expand All @@ -105,7 +105,7 @@
),
ctxt: #0,
},
value: Atom('access' type=inline),
value: "access",
},
tag: Access(
AccessTag {
Expand All @@ -128,7 +128,7 @@
),
ctxt: #0,
},
value: Atom('private' type=static),
value: "private",
},
},
),
Expand All @@ -155,7 +155,7 @@
),
ctxt: #0,
},
value: Atom('' type=static),
value: "",
},
tags: [
TagItem {
Expand All @@ -178,7 +178,7 @@
),
ctxt: #0,
},
value: Atom('access' type=inline),
value: "access",
},
tag: Access(
AccessTag {
Expand All @@ -201,7 +201,7 @@
),
ctxt: #0,
},
value: Atom('protected' type=static),
value: "protected",
},
},
),
Expand All @@ -228,7 +228,7 @@
),
ctxt: #0,
},
value: Atom('' type=static),
value: "",
},
tags: [
TagItem {
Expand All @@ -251,7 +251,7 @@
),
ctxt: #0,
},
value: Atom('access' type=inline),
value: "access",
},
tag: Access(
AccessTag {
Expand All @@ -274,7 +274,7 @@
),
ctxt: #0,
},
value: Atom('public' type=static),
value: "public",
},
},
),
Expand All @@ -301,7 +301,7 @@
),
ctxt: #0,
},
value: Atom('nothing' type=inline),
value: "nothing",
},
tags: [],
},
Expand All @@ -325,7 +325,7 @@
),
ctxt: #0,
},
value: Atom('' type=static),
value: "",
},
tags: [
TagItem {
Expand All @@ -348,7 +348,7 @@
),
ctxt: #0,
},
value: Atom('constructor' type=static),
value: "constructor",
},
tag: Class(
ClassTag {
Expand Down Expand Up @@ -388,7 +388,7 @@
),
ctxt: #0,
},
value: Atom('' type=static),
value: "",
},
tags: [
TagItem {
Expand All @@ -411,7 +411,7 @@
),
ctxt: #0,
},
value: Atom('private' type=static),
value: "private",
},
tag: Private(
PrivateTag {
Expand Down Expand Up @@ -450,7 +450,7 @@
),
ctxt: #0,
},
value: Atom('' type=static),
value: "",
},
tags: [
TagItem {
Expand All @@ -473,7 +473,7 @@
),
ctxt: #0,
},
value: Atom('protected' type=static),
value: "protected",
},
tag: Protected(
ProtectedTag {
Expand Down Expand Up @@ -512,7 +512,7 @@
),
ctxt: #0,
},
value: Atom('' type=static),
value: "",
},
tags: [
TagItem {
Expand All @@ -535,7 +535,7 @@
),
ctxt: #0,
},
value: Atom('public' type=static),
value: "public",
},
tag: Public(
PublicTag {
Expand Down Expand Up @@ -573,7 +573,7 @@
),
ctxt: #0,
},
value: Atom('nothing' type=inline),
value: "nothing",
},
tags: [],
},
Expand Down
10 changes: 5 additions & 5 deletions crates/jsdoc/tests/fixtures/alias.debug
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
),
ctxt: #0,
},
value: Atom('Give x another name.' type=dynamic),
value: "Give x another name.",
},
tags: [
TagItem {
Expand All @@ -42,7 +42,7 @@
),
ctxt: #0,
},
value: Atom('alias' type=inline),
value: "alias",
},
tag: Alias(
AliasTag {
Expand Down Expand Up @@ -76,7 +76,7 @@
),
ctxt: #0,
},
value: Atom('myObject' type=dynamic),
value: "myObject",
},
],
},
Expand All @@ -103,7 +103,7 @@
),
ctxt: #0,
},
value: Atom('namespace' type=static),
value: "namespace",
},
tag: Namespace(
NamespaceTag {
Expand Down Expand Up @@ -143,7 +143,7 @@
),
ctxt: #0,
},
value: Atom('document me' type=dynamic),
value: "document me",
},
tags: [],
},
Expand Down
Loading

1 comment on commit 84cec87

@github-actions
Copy link

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: 84cec87 Previous: 1346528 Ratio
es/full/bugs-1 285380 ns/iter (± 2726) 278775 ns/iter (± 3622) 1.02
es/full/minify/libraries/antd 1363954658 ns/iter (± 7157316) 1348747650 ns/iter (± 20880960) 1.01
es/full/minify/libraries/d3 294764679 ns/iter (± 6537872) 279315887 ns/iter (± 2735956) 1.06
es/full/minify/libraries/echarts 1096032335 ns/iter (± 6269448) 1085681060 ns/iter (± 10609841) 1.01
es/full/minify/libraries/jquery 89297589 ns/iter (± 390797) 85266846 ns/iter (± 491540) 1.05
es/full/minify/libraries/lodash 104805004 ns/iter (± 947027) 98390273 ns/iter (± 338484) 1.07
es/full/minify/libraries/moment 52828049 ns/iter (± 69931) 50482707 ns/iter (± 295110) 1.05
es/full/minify/libraries/react 18942840 ns/iter (± 192964) 18090868 ns/iter (± 84462) 1.05
es/full/minify/libraries/terser 232318032 ns/iter (± 1329303) 224326908 ns/iter (± 1727218) 1.04
es/full/minify/libraries/three 406556728 ns/iter (± 2309386) 398686673 ns/iter (± 3023189) 1.02
es/full/minify/libraries/typescript 2741127697 ns/iter (± 8581147) 2694968376 ns/iter (± 16756286) 1.02
es/full/minify/libraries/victory 592892850 ns/iter (± 5810473) 607050069 ns/iter (± 5494820) 0.98
es/full/minify/libraries/vue 126982145 ns/iter (± 584424) 122245938 ns/iter (± 1106682) 1.04
es/full/codegen/es3 33886 ns/iter (± 102) 34444 ns/iter (± 107) 0.98
es/full/codegen/es5 34037 ns/iter (± 103) 34379 ns/iter (± 54) 0.99
es/full/codegen/es2015 34004 ns/iter (± 59) 34370 ns/iter (± 68) 0.99
es/full/codegen/es2016 33957 ns/iter (± 101) 34280 ns/iter (± 67) 0.99
es/full/codegen/es2017 34001 ns/iter (± 112) 34466 ns/iter (± 70) 0.99
es/full/codegen/es2018 34075 ns/iter (± 52) 34399 ns/iter (± 79) 0.99
es/full/codegen/es2019 34043 ns/iter (± 87) 34376 ns/iter (± 81) 0.99
es/full/codegen/es2020 34146 ns/iter (± 78) 34410 ns/iter (± 75) 0.99
es/full/all/es3 177598940 ns/iter (± 1154945) 166827572 ns/iter (± 4196051) 1.06
es/full/all/es5 169501722 ns/iter (± 1229149) 158481136 ns/iter (± 3917806) 1.07
es/full/all/es2015 128214555 ns/iter (± 1542772) 119137280 ns/iter (± 829015) 1.08
es/full/all/es2016 127174762 ns/iter (± 1320632) 118384259 ns/iter (± 2056572) 1.07
es/full/all/es2017 126875607 ns/iter (± 1501540) 117639772 ns/iter (± 861769) 1.08
es/full/all/es2018 124317760 ns/iter (± 1004776) 115718330 ns/iter (± 861068) 1.07
es/full/all/es2019 123960431 ns/iter (± 453994) 114049899 ns/iter (± 1136600) 1.09
es/full/all/es2020 120472035 ns/iter (± 408467) 110258029 ns/iter (± 1869779) 1.09
es/full/parser 570220 ns/iter (± 4220) 512638 ns/iter (± 5080) 1.11
es/full/base/fixer 19478 ns/iter (± 174) 18063 ns/iter (± 134) 1.08
es/full/base/resolver_and_hygiene 82084 ns/iter (± 261) 81232 ns/iter (± 229) 1.01

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.