(index) Use MemorySegment.copy for LongArray->LongArray transfers

This commit is contained in:
Viktor Lofgren 2024-09-17 13:49:02 +02:00
parent b95646625f
commit 9f9c6736ab
2 changed files with 10 additions and 6 deletions

View File

@ -182,9 +182,11 @@ public class SegmentLongArray implements LongArray {
if (destEndL > size())
throw new IndexOutOfBoundsException("Destination array too small");
for (long i = destStartL; i < destEndL; i++) {
set(i, source.get(sourceStartL + i - destStartL));
}
MemorySegment.copy(
source.getMemorySegment(), JAVA_LONG, sourceStartL,
segment, JAVA_LONG, destStartL,
destEndL - destStartL
);
}
@Override

View File

@ -283,9 +283,11 @@ public class UnsafeLongArray implements LongArray {
if (destEndL > size())
throw new IndexOutOfBoundsException("Destination array too small");
for (long i = destStartL; i < destEndL; i++) {
set(i, source.get(sourceStartL + i - destStartL));
}
MemorySegment.copy(
source.getMemorySegment(), JAVA_LONG, sourceStartL,
segment, JAVA_LONG, destStartL,
destEndL - destStartL
);
}
}