aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Michajlo Matijkiw <michajlo@google.com>2015-09-03 17:49:57 +0000
committerGravatar David Chen <dzc@google.com>2015-09-03 22:17:14 +0000
commit2c3b120a26612c5ad4856c043e888468b39a5f46 (patch)
tree8f0851039f79d60e6213f4ffc660da687db23fe8 /src/main/java/com
parent4226be2ddaf265c1eba70f28e0ed1d9578cf6690 (diff)
Remove unused ParserInputSource method and other minor cleanups
Trying to curb usage of the create method taking a String for efficiency reasons. Noticed this method was unused + a few places where we could easily use chars instead of string. Not a major improvement but removes some temptation. RELNOTES: -- MOS_MIGRATED_REVID=102258319
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/google/devtools/build/lib/packages/Preprocessor.java8
-rw-r--r--src/main/java/com/google/devtools/build/lib/syntax/ParserInputSource.java19
2 files changed, 5 insertions, 22 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/packages/Preprocessor.java b/src/main/java/com/google/devtools/build/lib/packages/Preprocessor.java
index 834fcaef36..a479ca9f55 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/Preprocessor.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/Preprocessor.java
@@ -90,6 +90,8 @@ public interface Preprocessor {
* A (result, success) tuple indicating the outcome of preprocessing.
*/
static class Result {
+ private static final char[] EMPTY_CHARS = new char[0];
+
public final ParserInputSource result;
public final boolean preprocessed;
public final boolean containsErrors;
@@ -103,7 +105,7 @@ public interface Preprocessor {
this.containsTransientErrors = containsTransientErrors;
}
- /** Convenience factory for a {@link Result} wrapping non-preprocessed BUILD file contents. */
+ /** Convenience factory for a {@link Result} wrapping non-preprocessed BUILD file contents. */
public static Result noPreprocessing(ParserInputSource buildFileSource) {
return new Result(buildFileSource, /*preprocessed=*/false, /*containsErrors=*/false,
/*containsTransientErrors=*/false);
@@ -120,12 +122,12 @@ public interface Preprocessor {
}
public static Result invalidSyntax(PathFragment buildFile) {
- return new Result(ParserInputSource.create("", buildFile), /*preprocessed=*/true,
+ return new Result(ParserInputSource.create(EMPTY_CHARS, buildFile), /*preprocessed=*/true,
/*containsPersistentErrors=*/true, /*containsTransientErrors=*/false);
}
public static Result transientError(PathFragment buildFile) {
- return new Result(ParserInputSource.create("", buildFile), /*preprocessed=*/false,
+ return new Result(ParserInputSource.create(EMPTY_CHARS, buildFile), /*preprocessed=*/false,
/*containsPersistentErrors=*/false, /*containsTransientErrors=*/true);
}
}
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/ParserInputSource.java b/src/main/java/com/google/devtools/build/lib/syntax/ParserInputSource.java
index 6cfdc94b00..82b2a442e0 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/ParserInputSource.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/ParserInputSource.java
@@ -18,7 +18,6 @@ import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.io.IOException;
-import java.io.InputStream;
/**
* An abstraction for reading input from a file or taking it as a pre-cooked
@@ -84,22 +83,4 @@ public abstract class ParserInputSource {
}
};
}
-
- /**
- * Create an input source from the given input stream, and associate path
- * with this source. 'path' will be used in error messages, etc, but will
- * not (in general) be used to to read the content from path.
- *
- * <p>(The exception is the case in which Python pre-processing is required; the
- * path will be used to provide the input to the Python pre-processor.
- * Arguably, we should just send the content as input to the subprocess
- * instead of using the path, but it's not clear it's worth the effort.)
- */
- public static ParserInputSource create(InputStream in, Path path) throws IOException {
- try {
- return create(new String(FileSystemUtils.readContentAsLatin1(in)), path.asFragment());
- } finally {
- in.close();
- }
- }
}