fix bytearray:insert (#594)
This commit is contained in:
parent
a46aafa562
commit
25f4c7fbdd
@ -28,3 +28,9 @@ assert(#arr == arr:get_capacity())
|
||||
|
||||
arr = Bytearray({0, 2, 7, 1, 16, 75, 25})
|
||||
assert(arr[6] == 75)
|
||||
|
||||
arr:insert(2, {5, 6})
|
||||
|
||||
assert(arr[#arr] == 25)
|
||||
assert(arr[2] == 5)
|
||||
assert(arr[3] == 6)
|
||||
|
||||
@ -71,7 +71,7 @@ local function insert(self, index, b)
|
||||
if self.size + elems > self.capacity then
|
||||
grow_buffer(self, elems)
|
||||
end
|
||||
for i=self.size, index - 1, -1 do
|
||||
for i = self.size - 1, index - 1, -1 do
|
||||
self.bytes[i + elems] = self.bytes[i]
|
||||
end
|
||||
if _type(b) == "number" then
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user