Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.0
-
None
Description
The following two methods Engine.createScript() and Engine.createExpression() are calling JexlEngine.createInfo() when debug mode is enabled and JexlInfo is not provided. But if caching is enabled the method Engine.parse() will not use provided JexlInfo if the requested statement is already in the cache. This leads to sub-optimal performance, in my measurements up to 100 times slower. The suggestion is to refactor by removing the following code
if (info == null && debug) { info = createInfo(); }
from methods Engine.createScript() and Engine.createExpression() and adding to the method Engine.parse() after the cache check, like this
protected ASTJexlScript parse(JexlInfo info, String src, Scope scope, boolean registers, boolean expression) { final boolean cached = src.length() < cacheThreshold && cache != null; ASTJexlScript script; synchronized (parser) { if (cached) { script = cache.get(src); if (script != null) { Scope f = script.getScope(); if ((f == null && scope == null) || (f != null && f.equals(scope))) { return script; } } } if (info == null && debug) { info = createInfo(); } script = parser.parse(info, src, scope, registers, expression); if (cached) { cache.put(src, script); } } return script; }