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

已关闭
ranides4 年之前创建 · 2 条评论
ranides 评论于 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 评论于 4 年之前
所有者

The same applies to all comparators

The same applies to all comparators
ranides 评论于 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 年之前 关闭
登录 并参与到对话中。
未选择里程碑
未指派成员
1 名参与者
正在加载...
取消
保存
这个人很懒,什么都没留下。