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]`
|
// `val` is array.data and user facing usage is `a << [1,2,3]`
|
||||||
[unsafe]
|
[unsafe]
|
||||||
pub fn (mut a3 array) push_many(val voidptr, size int) {
|
pub fn (mut a3 array) push_many(val voidptr, size int) {
|
||||||
|
if size <= 0 || isnil(val) {
|
||||||
|
return
|
||||||
|
}
|
||||||
a3.ensure_cap(a3.len + size)
|
a3.ensure_cap(a3.len + size)
|
||||||
if a3.data == val && a3.data != 0 {
|
if a3.data == val && a3.data != 0 {
|
||||||
// handle `arr << arr`
|
// 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]`
|
// `val` is array.data and user facing usage is `a << [1,2,3]`
|
||||||
[unsafe]
|
[unsafe]
|
||||||
fn (mut a3 array) push_many_noscan(val voidptr, size int) {
|
fn (mut a3 array) push_many_noscan(val voidptr, size int) {
|
||||||
|
if size <= 0 || isnil(val) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if a3.data == val && a3.data != 0 {
|
if a3.data == val && a3.data != 0 {
|
||||||
// handle `arr << arr`
|
// handle `arr << arr`
|
||||||
copy := a3.clone()
|
copy := a3.clone()
|
||||||
|
|
Loading…
Reference in New Issue