Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
In CompiledIn.evaluate we can see repetitive loops, each one differing only in the cast to a specific array type. For example:
// handle each type of primitive array
if (evalColln instanceof long[]) {
long[] a = (long[])evalColln;
for (int i = 0; i < a.length; i++) {
Object e = Long.valueOf(a[i]);
if (TypeUtils.compare(evalElm, e, TOK_EQ).equals(Boolean.TRUE))
}
return Boolean.FALSE;
}
if (evalColln instanceof double[]) {
double[] a = (double[])evalColln;
for (int i = 0; i < a.length; i++) {
Object e = Double.valueOf(a[i]);
if (TypeUtils.compare(evalElm, e, TOK_EQ).equals(Boolean.TRUE)) { return Boolean.TRUE; }
}
return Boolean.FALSE;
}
We should be able to write a test to exercise this code and then write a single loop that handles all object thypes as the comparison is actually done by the TypeUtils.compare() method.