Skip to content

Commit

Permalink
Revert "fix(es/transform/compat): Preserve more span (#2766)"
Browse files Browse the repository at this point in the history
This reverts commit ddfc7e6.
  • Loading branch information
kdy1 authored Nov 17, 2021
1 parent e03af45 commit 1a7cab4
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 117 deletions.
13 changes: 0 additions & 13 deletions crates/swc/tests/fixture/issue-2701/1/input/.swcrc

This file was deleted.

22 changes: 0 additions & 22 deletions crates/swc/tests/fixture/issue-2701/1/input/index.js

This file was deleted.

61 changes: 0 additions & 61 deletions crates/swc/tests/fixture/issue-2701/1/output/index.js

This file was deleted.

23 changes: 2 additions & 21 deletions crates/swc_ecma_transforms_compat/src/es2017/async_to_generator.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{iter, mem::replace};
use swc_common::{util::take::Take, BytePos, Mark, Span, Spanned, SyntaxContext, DUMMY_SP};
use swc_common::{util::take::Take, Mark, Span, Spanned, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_transforms_base::{helper, perf::Check};
use swc_ecma_transforms_macros::fast_path;
Expand Down Expand Up @@ -429,28 +429,9 @@ impl VisitMut for Actual {
})
};

let func_span_lo = {
let key_span_lo = match &prop.key {
PropName::Ident(ident) => ident.span().lo(),
PropName::Str(str) => str.span().lo(),
PropName::Num(num) => num.span().lo(),
PropName::Computed(computed) => computed.span().lo(),
PropName::BigInt(bigint) => bigint.span().lo(),
};

// sub length of "async " from prop's key span
key_span_lo - BytePos(6)
};

let func_span = Span::new(
func_span_lo,
func_span_lo + BytePos(1), // dummy pos
SyntaxContext::empty(),
);

prop.function = Function {
params: original_fn_params,
span: func_span,
span: prop_method_span,
is_async: false,
is_generator: false,
body: Some(BlockStmt {
Expand Down

1 comment on commit 1a7cab4

@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: 1a7cab4 Previous: ddfc7e6 Ratio
base_tr_fixer 27334 ns/iter (± 271) 30512 ns/iter (± 3712) 0.90
base_tr_resolver_and_hygiene 153988 ns/iter (± 29265) 180847 ns/iter (± 22035) 0.85
codegen_es2015 61734 ns/iter (± 4647) 63344 ns/iter (± 16513) 0.97
codegen_es2016 61364 ns/iter (± 512) 63739 ns/iter (± 5210) 0.96
codegen_es2017 61423 ns/iter (± 599) 64158 ns/iter (± 13140) 0.96
codegen_es2018 61765 ns/iter (± 724) 61324 ns/iter (± 6888) 1.01
codegen_es2019 66679 ns/iter (± 6455) 62470 ns/iter (± 10523) 1.07
codegen_es2020 61942 ns/iter (± 1064) 63093 ns/iter (± 5669) 0.98
codegen_es3 61532 ns/iter (± 458) 62132 ns/iter (± 11707) 0.99
codegen_es5 61887 ns/iter (± 484) 62427 ns/iter (± 12827) 0.99
full_es2015 217755629 ns/iter (± 8936067) 220666982 ns/iter (± 20271557) 0.99
full_es2016 167448458 ns/iter (± 8104853) 170988815 ns/iter (± 13483924) 0.98
full_es2017 179833195 ns/iter (± 10564930) 182854249 ns/iter (± 31450064) 0.98
full_es2018 179927231 ns/iter (± 13654449) 182000630 ns/iter (± 17537020) 0.99
full_es2019 178641807 ns/iter (± 15386851) 180502044 ns/iter (± 21133980) 0.99
full_es2020 177197445 ns/iter (± 13980462) 180503881 ns/iter (± 27290393) 0.98
full_es3 267206101 ns/iter (± 14601652) 275222220 ns/iter (± 72162327) 0.97
full_es5 246813335 ns/iter (± 8531896) 256186026 ns/iter (± 44495548) 0.96
parser 765232 ns/iter (± 30441) 842002 ns/iter (± 320395) 0.91
ser_ast_node 173 ns/iter (± 2) 178 ns/iter (± 19) 0.97
ser_serde 190 ns/iter (± 8) 196 ns/iter (± 24) 0.97
emit_colors 20622150 ns/iter (± 26509643) 19060238 ns/iter (± 22639978) 1.08
emit_large 108644841 ns/iter (± 166806691) 98856654 ns/iter (± 143815782) 1.10
base_clone 2950755 ns/iter (± 275805) 3047992 ns/iter (± 679324) 0.97
fold_span 5084943 ns/iter (± 494736) 5124571 ns/iter (± 919512) 0.99
fold_span_panic 5425113 ns/iter (± 366017) 4991137 ns/iter (± 883039) 1.09
visit_mut_span 3776990 ns/iter (± 398042) 5355039 ns/iter (± 2163489) 0.71
visit_mut_span_panic 3755134 ns/iter (± 363135) 5382532 ns/iter (± 880909) 0.70
ast_clone 19538 ns/iter (± 149) 23657 ns/iter (± 2955) 0.83
ast_clone_to_stable 59250 ns/iter (± 590) 73062 ns/iter (± 6716) 0.81
ast_clone_to_stable_then_to_unstable 108541 ns/iter (± 715) 132972 ns/iter (± 20605) 0.82
json_deserialize 2318035 ns/iter (± 10991) 2493953 ns/iter (± 538910) 0.93
json_serialize 110662 ns/iter (± 506) 109436 ns/iter (± 32947) 1.01
boxing_boxed 173 ns/iter (± 1) 163 ns/iter (± 21) 1.06
boxing_boxed_clone 81 ns/iter (± 0) 77 ns/iter (± 13) 1.05
boxing_unboxed 155 ns/iter (± 0) 181 ns/iter (± 34) 0.86
boxing_unboxed_clone 77 ns/iter (± 0) 77 ns/iter (± 10) 1

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

Please sign in to comment.