Skip to content

Commit

Permalink
feat(es/parser): Implement AsRef<str> for IdentLike (#8133)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Oct 18, 2023
1 parent 5bb63aa commit bffe33a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crates/swc_ecma_parser/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,15 @@ impl From<&'_ str> for IdentLike {
}
}

impl AsRef<str> for IdentLike {
fn as_ref(&self) -> &str {
match self {
IdentLike::Known(k) => (*k).into(),
IdentLike::Other(s) => s.as_ref(),
}
}
}

impl From<Keyword> for Word {
fn from(kwd: Keyword) -> Self {
Word::Keyword(kwd)
Expand Down

1 comment on commit bffe33a

@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: bffe33a Previous: 111de26 Ratio
es/full/bugs-1 284101 ns/iter (± 5089) 288829 ns/iter (± 4729) 0.98
es/full/minify/libraries/antd 1402131384 ns/iter (± 13074805) 1389036540 ns/iter (± 21284821) 1.01
es/full/minify/libraries/d3 295972404 ns/iter (± 2395737) 294138948 ns/iter (± 3409382) 1.01
es/full/minify/libraries/echarts 1129919682 ns/iter (± 4272904) 1109978388 ns/iter (± 7166441) 1.02
es/full/minify/libraries/jquery 89298718 ns/iter (± 208814) 88689893 ns/iter (± 223944) 1.01
es/full/minify/libraries/lodash 104544053 ns/iter (± 266372) 103844115 ns/iter (± 205738) 1.01
es/full/minify/libraries/moment 52651896 ns/iter (± 107827) 52339031 ns/iter (± 105814) 1.01
es/full/minify/libraries/react 18967284 ns/iter (± 110836) 18844953 ns/iter (± 60064) 1.01
es/full/minify/libraries/terser 230975986 ns/iter (± 825561) 228399108 ns/iter (± 325412) 1.01
es/full/minify/libraries/three 413013854 ns/iter (± 2520735) 409129572 ns/iter (± 3074984) 1.01
es/full/minify/libraries/typescript 2792014299 ns/iter (± 7520902) 2760432748 ns/iter (± 14531611) 1.01
es/full/minify/libraries/victory 599994242 ns/iter (± 2696170) 590763185 ns/iter (± 4211196) 1.02
es/full/minify/libraries/vue 128628100 ns/iter (± 1047610) 126254991 ns/iter (± 968542) 1.02
es/full/codegen/es3 35326 ns/iter (± 143) 34082 ns/iter (± 92) 1.04
es/full/codegen/es5 35517 ns/iter (± 146) 34171 ns/iter (± 128) 1.04
es/full/codegen/es2015 35375 ns/iter (± 97) 34093 ns/iter (± 133) 1.04
es/full/codegen/es2016 35429 ns/iter (± 40) 33986 ns/iter (± 148) 1.04
es/full/codegen/es2017 35361 ns/iter (± 98) 34115 ns/iter (± 97) 1.04
es/full/codegen/es2018 35489 ns/iter (± 171) 34052 ns/iter (± 214) 1.04
es/full/codegen/es2019 35412 ns/iter (± 127) 34122 ns/iter (± 132) 1.04
es/full/codegen/es2020 35461 ns/iter (± 125) 34160 ns/iter (± 81) 1.04
es/full/all/es3 176745682 ns/iter (± 1104320) 175675957 ns/iter (± 684933) 1.01
es/full/all/es5 169236775 ns/iter (± 1105646) 168845996 ns/iter (± 1550552) 1.00
es/full/all/es2015 128214840 ns/iter (± 694454) 127673298 ns/iter (± 985543) 1.00
es/full/all/es2016 126746080 ns/iter (± 878373) 126569701 ns/iter (± 503674) 1.00
es/full/all/es2017 126127936 ns/iter (± 680482) 125724545 ns/iter (± 606938) 1.00
es/full/all/es2018 124531356 ns/iter (± 668499) 123594957 ns/iter (± 631930) 1.01
es/full/all/es2019 123807639 ns/iter (± 840679) 122743563 ns/iter (± 1066059) 1.01
es/full/all/es2020 120288284 ns/iter (± 819585) 119250751 ns/iter (± 890148) 1.01
es/full/parser 565911 ns/iter (± 3729) 561468 ns/iter (± 3541) 1.01
es/full/base/fixer 19239 ns/iter (± 265) 18690 ns/iter (± 180) 1.03
es/full/base/resolver_and_hygiene 84076 ns/iter (± 206) 83334 ns/iter (± 239) 1.01

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

Please sign in to comment.