diff options
author | Googler <noreply@google.com> | 2016-06-20 22:51:10 +0000 |
---|---|---|
committer | Philipp Wollermann <philwo@google.com> | 2016-06-21 09:59:16 +0000 |
commit | cecca155c50b2b58890c7b84448d72c28a0ee7cf (patch) | |
tree | b9458b316a172a7fbba7cce78ca9f1d3b8491678 /src/main/java/com/google | |
parent | 1442442e9ddff85efdec0f34ac312a513962862c (diff) |
Optimize an assertion which was showing up in profiles. (Even better might be
to remove the call from RuleConfiguredTarget.getProvider() and instead check the
types when the providers ImmutableMap is built.)
--
MOS_MIGRATED_REVID=125389561
Diffstat (limited to 'src/main/java/com/google')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/AnalysisUtils.java | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/AnalysisUtils.java b/src/main/java/com/google/devtools/build/lib/analysis/AnalysisUtils.java index c350cb239a..40fdf9b6b1 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/AnalysisUtils.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/AnalysisUtils.java @@ -26,7 +26,6 @@ import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.collect.nestedset.Order; import com.google.devtools.build.lib.packages.BuildType; import com.google.devtools.build.lib.packages.TriState; -import com.google.devtools.build.lib.util.Preconditions; import com.google.devtools.build.lib.vfs.PathFragment; /** @@ -129,12 +128,11 @@ public final class AnalysisUtils { * Checks that the given provider class either refers to an interface or to a value class. */ public static <T extends TransitiveInfoProvider> void checkProvider(Class<T> clazz) { - if (!clazz.isInterface()) { - Preconditions.checkArgument( - !clazz.getSimpleName().startsWith("AutoValue_") || clazz.getSuperclass() == null, - "%s is generated by @AutoValue - you should use %s instead", - clazz.getSimpleName(), - clazz.getSuperclass().getSimpleName()); + // Write this check in terms of getName() rather than getSimpleName(); the latter is expensive. + if (!clazz.isInterface() && clazz.getName().contains(".AutoValue_")) { + // We must have a superclass due to the generic bound above. + throw new IllegalArgumentException( + clazz + " is generated by @AutoValue; use " + clazz.getSuperclass() + " instead"); } } } |