mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 22:11:51 +00:00
(i hope that correctry) optimized bytearray:move method
This commit is contained in:
parent
27bb3015e4
commit
0d641fa82f
1 changed files with 9 additions and 4 deletions
|
|
@ -185,10 +185,15 @@ local function move(self, fromindex, toindex, size)
|
||||||
fromindex + size - 1 <= self.size and
|
fromindex + size - 1 <= self.size and
|
||||||
toindex + size - 1 <= self.size
|
toindex + size - 1 <= self.size
|
||||||
then
|
then
|
||||||
local buff = malloc(size)
|
if toindex >= fromindex and toindex < fromindex + size then
|
||||||
FFI.copy(buff, self.bytes + fromindex - 1, size)
|
local buff = malloc(size)
|
||||||
FFI.copy(self.bytes + toindex - 1, buff, size)
|
FFI.copy(buff, self.bytes + fromindex - 1, size)
|
||||||
free(buff)
|
FFI.copy(self.bytes + toindex - 1, buff, size)
|
||||||
|
free(buff)
|
||||||
|
else
|
||||||
|
-- убери(-те) это ветвление, если FFI будет производить копирование не побайтово, и оставь(-те) только верхний блок без условия вообще.
|
||||||
|
FFI.copy(self.bytes + toindex - 1, self.bytes + fromindex - 1, size)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue