At this moment moveTo/moveFrom assumes that second array has identical type. If second array has different, even assign-compatible type, exception will be thrown because we will try to convert at array level.
It should be implemented in this way, that current implementation runs for identical types, and unoptimized version (which uses get/set) is returned in other cases.
At this moment moveTo/moveFrom assumes that second array has *identical* type. If second array has different, even assign-compatible type, exception will be thrown because we will try to convert at array level.
It should be implemented in this way, that current implementation runs for identical types, and unoptimized version (which uses get/set) is returned in other cases.
public IntComparator comparator(NativeArray values) {
DoubleArray that = (DoubleArray)values;
return (a,b) -> Double.compare(this.array[a], that.array[b]);
}
it can be transformed to:
public IntComparator comparator(NativeArray values) {
double[] other = values.$array();
return (a,b) -> Double.compare(this.array[a], other[b]);
}
That version of optimized operation will avoid accessing field over and over again.
comparators use cast at object level:
```
public IntComparator comparator(NativeArray values) {
DoubleArray that = (DoubleArray)values;
return (a,b) -> Double.compare(this.array[a], that.array[b]);
}
```
it can be transformed to:
```
public IntComparator comparator(NativeArray values) {
double[] other = values.$array();
return (a,b) -> Double.compare(this.array[a], other[b]);
}
```
That version of optimized operation will avoid accessing field over and over again.
At this moment moveTo/moveFrom assumes that second array has identical type. If second array has different, even assign-compatible type, exception will be thrown because we will try to convert at array level.
It should be implemented in this way, that current implementation runs for identical types, and unoptimized version (which uses get/set) is returned in other cases.
The same applies to all comparators
comparators use cast at object level:
it can be transformed to:
That version of optimized operation will avoid accessing field over and over again.