mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 10:31:50 +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
|
||||
toindex + size - 1 <= self.size
|
||||
then
|
||||
local buff = malloc(size)
|
||||
FFI.copy(buff, self.bytes + fromindex - 1, size)
|
||||
FFI.copy(self.bytes + toindex - 1, buff, size)
|
||||
free(buff)
|
||||
if toindex >= fromindex and toindex < fromindex + size then
|
||||
local buff = malloc(size)
|
||||
FFI.copy(buff, self.bytes + fromindex - 1, size)
|
||||
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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue