Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit cbf5cbf

Browse files
committed
Merge pull request #36 from benaadams/patch-1
Avoid unnecessary work for identical locations in Buffer.BlockCopy
2 parents 8dd39eb + a5dd659 commit cbf5cbf

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/vm/comutilnative.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,9 +1443,12 @@ FCIMPL5(VOID, Buffer::BlockCopy, ArrayBase *src, int srcOffset, ArrayBase *dst,
14431443
if (srcLen < (SIZE_T)srcOffset + (SIZE_T)count || dstLen < (SIZE_T)dstOffset + (SIZE_T)count) {
14441444
FCThrowArgumentVoid(NULL, W("Argument_InvalidOffLen"));
14451445
}
1446+
1447+
PTR_BYTE srcPtr = src->GetDataPtr() + srcOffset;
1448+
PTR_BYTE dstPtr = dst->GetDataPtr() + dstOffset;
14461449

1447-
if (count > 0) {
1448-
memmove(dst->GetDataPtr() + dstOffset, src->GetDataPtr() + srcOffset, count);
1450+
if ((srcPtr != dstPtr) && (count > 0)) {
1451+
memmove(dstPtr, srcPtr, count);
14491452
}
14501453

14511454
FC_GC_POLL();

0 commit comments

Comments
 (0)