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

Закрыто
4 лет назад открыта ranides · комментариев: 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 лет назад
Войдите, чтобы присоединиться к обсуждению.
Нет этапа
Нет ответственного
1 участников
Загрузка...
Отмена
Сохранить
Пока нет содержимого.