From b32b68f675a8f1b47e4847aa830dca14ba3d7bb0 Mon Sep 17 00:00:00 2001 From: "HuYingzhuo(hugo/hyzboy)" Date: Tue, 25 Jul 2023 22:17:26 +0800 Subject: [PATCH] improved DataArray<>::Insert --- inc/hgl/type/DataArray.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/inc/hgl/type/DataArray.h b/inc/hgl/type/DataArray.h index 5e1fcae..3eb55e8 100644 --- a/inc/hgl/type/DataArray.h +++ b/inc/hgl/type/DataArray.h @@ -559,13 +559,13 @@ namespace hgl if(count+data_number>alloc_count) { - int new_alloc_count=alloc_count+data_number; + int new_alloc_count=power_to_2(alloc_count+data_number); T *new_items=hgl_align_malloc(new_alloc_count); - hgl_cpy(new_items,items,pos); - hgl_cpy(new_items+pos,data,data_number); - hgl_cpy(new_items+pos+data_number,items+pos,(count-pos)); + if(pos>0) hgl_cpy(new_items,items,pos); + hgl_cpy(new_items+pos,data,data_number); + if(pos