cgen: add a minor optimisation for array.push_many (#14770)
parent
b89617726c
commit
01fdd5d07f
|
@ -636,6 +636,9 @@ fn (mut a array) push(val voidptr) {
|
|||
// `val` is array.data and user facing usage is `a << [1,2,3]`
|
||||
[unsafe]
|
||||
pub fn (mut a3 array) push_many(val voidptr, size int) {
|
||||
if size <= 0 || isnil(val) {
|
||||
return
|
||||
}
|
||||
a3.ensure_cap(a3.len + size)
|
||||
if a3.data == val && a3.data != 0 {
|
||||
// handle `arr << arr`
|
||||
|
|
|
@ -227,6 +227,9 @@ fn (mut a array) push_noscan(val voidptr) {
|
|||
// `val` is array.data and user facing usage is `a << [1,2,3]`
|
||||
[unsafe]
|
||||
fn (mut a3 array) push_many_noscan(val voidptr, size int) {
|
||||
if size <= 0 || isnil(val) {
|
||||
return
|
||||
}
|
||||
if a3.data == val && a3.data != 0 {
|
||||
// handle `arr << arr`
|
||||
copy := a3.clone()
|
||||
|
|
Loading…
Reference in New Issue