Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DROOLS-1701 Improved memory usage by EvaluationContextImpl #1

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
import org.kie.dmn.feel.lang.EvaluationContext;
import org.kie.dmn.feel.util.EvalHelper;

import java.util.ArrayDeque;
import java.util.Collection;
import java.util.Deque;
import java.util.HashMap;
import java.util.Map;
import java.util.Stack;
Expand All @@ -31,12 +33,12 @@
public class EvaluationContextImpl implements EvaluationContext {

private final FEELEventListenersManager eventsManager;
private Stack<ExecutionFrame> stack;
private ArrayDeque<ExecutionFrame> stack;
private DMNRuntime dmnRuntime;

public EvaluationContextImpl(FEELEventListenersManager eventsManager) {
this.eventsManager = eventsManager;
this.stack = new Stack<>();
this.stack = new ArrayDeque<>();
// we create a rootFrame to hold all the built in functions
push( RootExecutionFrame.INSTANCE );
// and then create a global frame to be the starting frame
Expand All @@ -62,7 +64,7 @@ public ExecutionFrame peek() {
return stack.peek();
}

public Stack<ExecutionFrame> getStack() {
public Deque<ExecutionFrame> getStack() {
return this.stack;
}

Expand Down Expand Up @@ -136,8 +138,8 @@ public boolean isDefined(String[] name) {
@Override
public Map<String, Object> getAllValues() {
Map<String, Object> values = new HashMap<>( );
for( int i = 0; i < stack.size(); i++ ) {
values.putAll( stack.get( i ).getAllValues() );
for (ExecutionFrame frame : stack) {
values.putAll( frame.getAllValues() );
}
return values;
}
Expand Down