diff --git a/src/com/google/javascript/jscomp/SourceFile.java b/src/com/google/javascript/jscomp/SourceFile.java index bad968cbc66..e43b08c72de 100644 --- a/src/com/google/javascript/jscomp/SourceFile.java +++ b/src/com/google/javascript/jscomp/SourceFile.java @@ -47,7 +47,6 @@ import java.util.Arrays; import java.util.Enumeration; import java.util.List; -import java.util.Objects; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -173,15 +172,10 @@ String getCodeNoCache() { } void setCode(String sourceCode) { - this.setCode(sourceCode, false); - } - - void setCode(String sourceCode, boolean removeUtf8Bom) { - if (removeUtf8Bom && sourceCode != null && sourceCode.startsWith(UTF8_BOM)) { - code = sourceCode.substring(UTF8_BOM.length()); - } else { - code = sourceCode; - } + code = + sourceCode != null && sourceCode.startsWith(UTF8_BOM) + ? sourceCode.substring(UTF8_BOM.length()) + : sourceCode; resetLineOffsets(); } @@ -616,7 +610,7 @@ public synchronized String getCode() throws IOException { throw new IOException("Failed to read: " + path + ", is this input UTF-8 encoded?", e); } - super.setCode(cachedCode, Objects.equals(this.getCharset(), inputCharset)); + super.setCode(cachedCode); // Byte Order Mark can be removed by setCode cachedCode = super.getCode(); } @@ -724,7 +718,7 @@ public synchronized String getCode() throws IOException { // Must close the stream or else the cache won't be cleared. inputStream.close(); - super.setCode(cachedCode, Objects.equals(this.getCharset(), StandardCharsets.UTF_8)); + super.setCode(cachedCode); // Byte Order Mark can be removed by setCode cachedCode = super.getCode(); }