Skip to content

Commit f18f8ca

Browse files
committed
Switch back to original get implementation
This reverts commits: * d316f03 * 823269a There are probably tricky and sensitive JIT decisions going on under the covers here. It seems ill-advised to mess around here, given that the performance changes have mixed results. So we live with the status quo.
1 parent 823269a commit f18f8ca

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/main/java/org/scijava/parsington/eval/AbstractEvaluator.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,18 @@ public void setStrict(final boolean strict) {
7373
this.strict = strict;
7474
}
7575

76-
/** Sentinel object to disambiguate between missing vars and null values. */
77-
private static final Object MISSING = new Object();
78-
7976
@Override
8077
public Object get(final String name) {
81-
final Object value = vars.getOrDefault(name, MISSING);
82-
if (value != MISSING) return value;
78+
// NB: Here, we look up the key twice: once with containsKey, then
79+
// again with get. You might think we could do better by ensuring only
80+
// one single hash map lookup. But the JIT is apparently sensitive in
81+
// unintuitive ways to changes here, as illustrated by commits:
82+
//
83+
// - d316f03cfe4ed705d159bb0cf689c7c2a9260698
84+
// - 823269a0e3140dead2819dd7ad4ba20f4439120f
85+
//
86+
// So we leave the logic as is, since nothing better has been found yet.
87+
if (vars.containsKey(name)) return vars.get(name);
8388
if (strict) throw new IllegalArgumentException("Unknown variable: " + name);
8489
return new Unresolved(name);
8590
}

0 commit comments

Comments
 (0)