8000 internal: do not read or assign quote properties without need · terser/terser@b192cc0 · GitHub
[go: up one dir, main page]

Skip to content

Commit b192cc0

Browse files
internal: do not read or assign quote properties without need
1 parent 281178d commit b192cc0

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

lib/ast.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,7 +2179,6 @@ var AST_ConciseMethod = DEFNODE("ConciseMethod", "quote static is_generator asyn
21792179

21802180
var AST_PrivateMethod = DEFNODE("PrivateMethod", "", function AST_PrivateMethod(props) {
21812181
if (props) {
2182-
this.quote = props.quote;
21832182
this.static = props.static;
21842183
this.is_generator = props.is_generator;
21852184
this.async = props.async;
@@ -2340,7 +2339,6 @@ var AST_ClassProperty = DEFNODE("ClassProperty", "static quote", function AST_Cl
23402339
var AST_ClassPrivateProperty = DEFNODE("ClassPrivateProperty", "", function AST_ClassPrivateProperty(props) {
23412340
if (props) {
23422341
this.static = props.static;
2343-
this.quote = props.quote;
23442342
this.key = props.key;
23452343
this.value = props.value;
23462344
this.start = props.start;
@@ -2700,12 +2698,12 @@ var AST_SymbolImport = DEFNODE("SymbolImport", null, function AST_SymbolImport(p
27002698
$documentation: "Symbol referring to an imported name",
27012699
}, AST_SymbolBlockDeclaration);
27022700

2703-
var AST_SymbolImportForeign = DEFNODE("SymbolImportForeign", null, function AST_SymbolImportForeign(props) {
2701+
var AST_SymbolImportForeign = DEFNODE("SymbolImportForeign", "quote", function AST_SymbolImportForeign(props) {
27042702
if (props) {
2703+
this.quote = props.quote;
27052704
this.scope = props.scope;
27062705
this.name = props.name;
27072706
this.thedef = props.thedef;
2708-
this.quote = props.quote;
27092707
this.start = props.start;
27102708
this.end = props.end;
27112709
}
@@ -2752,12 +2750,12 @@ var AST_SymbolRef = DEFNODE("SymbolRef", null, function AST_SymbolRef(props) {
27522750
$documentation: "Reference to some symbol (not definition/declaration)",
27532751
}, AST_Symbol);
27542752

2755-
var AST_SymbolExport = DEFNODE("SymbolExport", null, function AST_SymbolExport(props) {
2753+
var AST_SymbolExport = DEFNODE("SymbolExport", "quote", function AST_SymbolExport(props) {
27562754
if (props) {
2755+
this.quote = props.quote;
27572756
this.scope = props.scope;
27582757
this.name = props.name;
27592758
this.thedef = props.thedef;
2760-
this.quote = props.quote;
27612759
this.start = props.start;
27622760
this.end = props.end;
27632761
}
@@ -2767,12 +2765,12 @@ var AST_SymbolExport = DEFNODE("SymbolExport", null, function AST_SymbolExport(p
27672765
$documentation: "Symbol referring to a name to export",
27682766
}, AST_SymbolRef);
27692767

2770-
var AST_SymbolExportForeign = DEFNODE("SymbolExportForeign", null, function AST_SymbolExportForeign(props) {
2768+
var AST_SymbolExportForeign = DEFNODE("SymbolExportForeign", "quote", function AST_SymbolExportForeign(props) {
27712769
if (props) {
2770+
this.quote = props.quote;
27722771
this.scope = props.scope;
27732772
this.name = props.name;
27742773
this.thedef = props.thedef;
2775-
this.quote = props.quote;
27762774
this.start = props.start;
27772775
this.end = props.end;
27782776
}

lib/output.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,11 +1811,11 @@ function OutputStream(options) {
18111811
foreign_name.name;
18121812
if (!names_are_different &&
18131813
foreign_name.name === "*" &&
1814-
foreign_name.quote != self.name.quote) {
1814+
!!foreign_name.quote != !!self.name.quote) {
18151815
// export * as "*"
18161816
names_are_different = true;
18171817
}
1818-
var foreign_name_is_name = foreign_name.quote == null;
1818+
var foreign_name_is_name = !foreign_name.quote;
18191819
if (names_are_different) {
18201820
if (is_import) {
18211821
if (foreign_name_is_name) {
@@ -1824,7 +1824,7 @@ function OutputStream(options) {
18241824
output.print_string(foreign_name.name, foreign_name.quote);
18251825
}
18261826
} else {
1827-
if (self.name.quote == null) {
1827+
if (!self.name.quote) {
18281828
self.name.print(output);
18291829
} else {
18301830
output.print_string(self.name.name, self.name.quote);
@@ -1844,7 +1844,7 @@ function OutputStream(options) {
18441844
}
18451845
}
18461846
} else {
1847-
if (self.name.quote == null) {
1847+
if (!self.name.quote) {
18481848
self.name.print(output);
18491849
} else {
18501850
output.print_string(self.name.name, self.name.quote);
@@ -2233,7 +2233,7 @@ function OutputStream(options) {
22332233

22342234
output.print("#");
22352235

2236-
print_property_name(self.key.name, self.quote, output);
2236+
print_property_name(self.key.name, undefined, output);
22372237

22382238
if (self.value) {
22392239
output.print("=");

lib/parse.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2660,13 +2660,17 @@ function parse($TEXT, options) {
26602660
}
26612661

26622662
if (is_class) {
2663-
const key = get_symbol_ast(name, AST_SymbolClassProperty);
2664-
const quote = key instanceof AST_SymbolClassProperty
2665-
? property_token.quote
2666-
: undefined;
2663+
const AST_SymbolVariant = is_private
2664+
? AST_SymbolPrivateProperty
2665+
: AST_SymbolClassProperty;
26672666
const AST_ClassPropertyVariant = is_private
26682667
? AST_ClassPrivateProperty
26692668
: AST_ClassProperty;
2669+
2670+
const key = get_symbol_ast(name, AST_SymbolVariant);
2671+
const quote = key instanceof AST_SymbolClassProperty
2672+
? property_token.quote
2673+
: undefined;
26702674
if (is("operator", "=")) {
26712675
next();
26722676
return annotate(
@@ -2810,10 +2814,12 @@ function parse($TEXT, options) {
28102814
} else {
28112815
foreign_name = make_symbol(foreign_type, S.token.quote);
28122816
}
2813-
} else if (is_import) {
2814-
name = new type(foreign_name);
28152817
} else {
2816-
foreign_name = new foreign_type(name);
2818+
if (is_import) {
2819+
name = new type(foreign_name);
2820+
} else {
2821+
foreign_name = new foreign_type(name);
2822+
}
28172823
}
28182824

28192825
return new AST_NameMapping({

0 commit comments

Comments
 (0)
0