Skip to content

Commit

Permalink
Delete cachedSymbols from LoadStatement.
Browse files Browse the repository at this point in the history
We rarely need it, it's not useful to keep it in memory.

RELNOTES: None.
PiperOrigin-RevId: 165562119
  • Loading branch information
laurentlb authored and iirina committed Aug 18, 2017
1 parent 2b25a2a commit 3ca2a10
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
public final class LoadStatement extends Statement {

private final ImmutableMap<Identifier, String> symbolMap;
private final ImmutableList<Identifier> cachedSymbols; // to save time
private final StringLiteral imp;

/**
Expand All @@ -37,15 +36,14 @@ public final class LoadStatement extends Statement {
public LoadStatement(StringLiteral imp, Map<Identifier, String> symbolMap) {
this.imp = imp;
this.symbolMap = ImmutableMap.copyOf(symbolMap);
this.cachedSymbols = ImmutableList.copyOf(symbolMap.keySet());
}

public ImmutableMap<Identifier, String> getSymbolMap() {
return symbolMap;
}

public ImmutableList<Identifier> getSymbols() {
return cachedSymbols;
return ImmutableList.copyOf(symbolMap.keySet());
}

public StringLiteral getImport() {
Expand All @@ -57,7 +55,7 @@ public void prettyPrint(Appendable buffer, int indentLevel) throws IOException {
printIndent(buffer, indentLevel);
buffer.append("load(");
imp.prettyPrint(buffer);
for (Identifier symbol : cachedSymbols) {
for (Identifier symbol : symbolMap.keySet()) {
buffer.append(", ");
String origName = symbolMap.get(symbol);
if (origName.equals(symbol.getName())) {
Expand Down Expand Up @@ -112,7 +110,7 @@ public void accept(SyntaxTreeVisitor visitor) {

@Override
void validate(ValidationEnvironment env) throws EvalException {
for (Identifier symbol : cachedSymbols) {
for (Identifier symbol : symbolMap.keySet()) {
env.declare(symbol.getName(), getLocation());
}
}
Expand Down

0 comments on commit 3ca2a10

Please sign in to comment.