From 8c55a9ecd3b491a8ba9ebf2ae8c6f03b16b9d325 Mon Sep 17 00:00:00 2001 From: yuyi Date: Sun, 3 Apr 2022 16:04:18 +0800 Subject: [PATCH] builtin: minor optimization of array.push() and array.push_noscan() (#13904) --- vlib/builtin/array.v | 2 +- vlib/builtin/array_d_gcboehm_opt.v | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vlib/builtin/array.v b/vlib/builtin/array.v index 8531c8f288..32cf21e7a7 100644 --- a/vlib/builtin/array.v +++ b/vlib/builtin/array.v @@ -587,7 +587,7 @@ fn (mut a array) push(val voidptr) { if a.len >= a.cap { a.ensure_cap(a.len + 1) } - unsafe { vmemmove(&byte(a.data) + a.element_size * a.len, val, a.element_size) } + unsafe { vmemcpy(&byte(a.data) + a.element_size * a.len, val, a.element_size) } a.len++ } diff --git a/vlib/builtin/array_d_gcboehm_opt.v b/vlib/builtin/array_d_gcboehm_opt.v index 09a8799017..27f92cde69 100644 --- a/vlib/builtin/array_d_gcboehm_opt.v +++ b/vlib/builtin/array_d_gcboehm_opt.v @@ -213,7 +213,7 @@ fn (a &array) clone_to_depth_noscan(depth int) array { fn (mut a array) push_noscan(val voidptr) { a.ensure_cap_noscan(a.len + 1) - unsafe { vmemmove(&byte(a.data) + a.element_size * a.len, val, a.element_size) } + unsafe { vmemcpy(&byte(a.data) + a.element_size * a.len, val, a.element_size) } a.len++ }