Do not attempt to cache structured variable lookup in the case of the name not
suggesting a structured variable (containing a "."). This just needlessly
consumes memory at no runtime or garbage overhead.
RELNOTES: None.
@@ -344,6 +344,15 @@ public abstract class CcToolchainVariables implements CcToolchainVariablesApi {
return var;
}
+ if (!name.contains(".")) {
+ if (throwOnMissingVariable) {
+ throw new ExpansionException(
+ String.format(
+ "Invalid toolchain configuration: Cannot find variable named '%s'.", name));
+ }
+ return null;
+ }
+
if (structuredVariableCache == null) {
structuredVariableCache = Maps.newConcurrentMap();
}
