#80 NativeArray: fix moveTo, moveFrom if other array has different type

已關閉
ranides4 年之前創建 · 2 條評論
ranides commented 4 年之前

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.
ranides commented 4 年之前
所有者

The same applies to all comparators

The same applies to all comparators
ranides commented 4 年之前
所有者

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.

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.
ranides 在代碼提交 3 年之前 中引用了該問題
ranides3 年之前 關閉
Sign in to join this conversation.
未選擇里程碑
未指派成員
1 參與者
正在加載...
取消
保存
尚未有任何內容