Skip to content

Commit

Permalink
Merge pull request #3339 from nieqiurong/20241228
Browse files Browse the repository at this point in the history
Sharing ExpressionEvaluator instances
  • Loading branch information
hazendaz authored Dec 31, 2024
2 parents 27ca11c + ced0088 commit af93a2b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
*/
public class ExpressionEvaluator {

public static final ExpressionEvaluator INSTANCE = new ExpressionEvaluator();

public boolean evaluateBoolean(String expression, Object parameterObject) {
Object value = OgnlCache.getValue(expression, parameterObject);
if (value instanceof Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public class ForEachSqlNode implements SqlNode {
public static final String ITEM_PREFIX = "__frch_";

private final ExpressionEvaluator evaluator;
private final ExpressionEvaluator evaluator = ExpressionEvaluator.INSTANCE;
private final String collectionExpression;
private final Boolean nullable;
private final SqlNode contents;
Expand All @@ -53,7 +53,6 @@ public ForEachSqlNode(Configuration configuration, SqlNode contents, String coll
*/
public ForEachSqlNode(Configuration configuration, SqlNode contents, String collectionExpression, Boolean nullable,
String index, String item, String open, String close, String separator) {
this.evaluator = new ExpressionEvaluator();
this.collectionExpression = collectionExpression;
this.nullable = nullable;
this.contents = contents;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
* @author Clinton Begin
*/
public class IfSqlNode implements SqlNode {
private final ExpressionEvaluator evaluator;
private final ExpressionEvaluator evaluator = ExpressionEvaluator.INSTANCE;
private final String test;
private final SqlNode contents;

public IfSqlNode(SqlNode contents, String test) {
this.test = test;
this.contents = contents;
this.evaluator = new ExpressionEvaluator();
}

@Override
Expand Down

0 comments on commit af93a2b

Please sign in to comment.