From 8ebdcf55abc911ae3130278a6ef10ca35736bce5 Mon Sep 17 00:00:00 2001 From: johnlenz Date: Fri, 31 Jan 2025 16:09:41 +0000 Subject: [PATCH] Delete unused method `JSChunk.addAndOverrideChunk`. While we are here remove an redundant hash lookup in `JSChunk.add`. PiperOrigin-RevId: 721777438 --- src/com/google/javascript/jscomp/JSChunk.java | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/com/google/javascript/jscomp/JSChunk.java b/src/com/google/javascript/jscomp/JSChunk.java index ef3bdcb5c10..e491a877231 100644 --- a/src/com/google/javascript/jscomp/JSChunk.java +++ b/src/com/google/javascript/jscomp/JSChunk.java @@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -148,24 +149,11 @@ public void add(SourceFile file) { /** Adds a source code input to this chunk. */ public void add(CompilerInput input) { String inputName = input.getName(); - checkArgument( - !inputs.containsKey(inputName), "%s already exist in chunk %s", inputName, this.getName()); - inputs.put(inputName, input); + CompilerInput previous = inputs.put(inputName, input); + checkState(previous == null, "%s already exist in chunk %s", inputName, this.getName()); input.setChunk(this); } - /** - * Adds a source code input to this chunk. Call only if the input might already be associated with - * a chunk. Otherwise, use add(CompilerInput input). - */ - void addAndOverrideChunk(CompilerInput input) { - String inputName = input.getName(); - checkArgument( - !inputs.containsKey(inputName), "%s already exist in chunk %s", inputName, this.getName()); - inputs.put(inputName, input); - input.overrideModule(this); - } - /** Adds a dependency on another chunk. */ public void addDependency(JSChunk dep) { checkNotNull(dep);