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

This commit is contained in:
Viktor Lofgren 2024-09-17 13:56:31 +02:00
parent a74df7f905
commit 60ad4786bc
2 changed files with 6 additions and 4 deletions

View File

@ -183,10 +183,11 @@ public class SegmentLongArray implements LongArray {
throw new IndexOutOfBoundsException("Destination array too small"); throw new IndexOutOfBoundsException("Destination array too small");
MemorySegment.copy( MemorySegment.copy(
source.getMemorySegment(), JAVA_LONG, sourceStartL, source.getMemorySegment(), JAVA_LONG, sourceStartL * JAVA_LONG.byteSize(),
segment, JAVA_LONG, destStartL, segment, JAVA_LONG, destStartL * JAVA_LONG.byteSize(),
destEndL - destStartL destEndL - destStartL
); );
} }
@Override @Override

View File

@ -284,10 +284,11 @@ public class UnsafeLongArray implements LongArray {
throw new IndexOutOfBoundsException("Destination array too small"); throw new IndexOutOfBoundsException("Destination array too small");
MemorySegment.copy( MemorySegment.copy(
source.getMemorySegment(), JAVA_LONG, sourceStartL, source.getMemorySegment(), JAVA_LONG, sourceStartL * JAVA_LONG.byteSize(),
segment, JAVA_LONG, destStartL, segment, JAVA_LONG, destStartL * JAVA_LONG.byteSize(),
destEndL - destStartL destEndL - destStartL
); );
} }
} }