Skip to content

Commit 6f54038

Browse files
lauraharkercopybara-github
authored andcommitted
Avoid eagerly calculating scope.getClosestHoistScope() in property collapsing
PiperOrigin-RevId: 704754433
1 parent 54f9f2f commit 6f54038

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/com/google/javascript/jscomp/InlineAndCollapseProperties.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -368,14 +368,15 @@ private void inlineAliases(GlobalNamespace namespace) {
368368
private void inlineAliasesForName(Name name, GlobalNamespace namespace) {
369369
List<Ref> refs = new ArrayList<>(name.getRefs());
370370
for (Ref ref : refs) {
371-
Scope hoistScope = ref.scope.getClosestHoistScope();
372371
if (ref.isAliasingGet() && !mayBeGlobalAlias(ref) && !ref.isTwin()) {
373372
// {@code name} meets condition (c). Try to inline it.
374373
// TODO(johnlenz): consider picking up new aliases at the end
375374
// of the pass instead of immediately like we do for global
376375
// inlines.
377376
inlineAliasIfPossible(name, ref, namespace);
378-
} else if (ref.isAliasingGet() && hoistScope.isGlobal() && !ref.isTwin()) {
377+
} else if (ref.isAliasingGet()
378+
&& ref.scope.getClosestHoistScope().isGlobal()
379+
&& !ref.isTwin()) {
379380
inlineGlobalAliasIfPossible(name, ref, namespace);
380381
} else if (name.isClass() && ref.isSubclassingGet() && name.props != null) {
381382
for (Name prop : name.props) {

0 commit comments

Comments
 (0)