From b3febf00179f46ae54b22d71617aa977fb1e86ef Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Tue, 13 Jul 2021 20:06:21 +0300 Subject: [PATCH] sq_newarrayex utility which reserves space only instead of creating elements. --- vendor/Squirrel/include/squirrelex.h | 1 + vendor/Squirrel/sqapiex.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/vendor/Squirrel/include/squirrelex.h b/vendor/Squirrel/include/squirrelex.h index 0742cb48..b58da89b 100644 --- a/vendor/Squirrel/include/squirrelex.h +++ b/vendor/Squirrel/include/squirrelex.h @@ -16,6 +16,7 @@ SQUIRREL_API SQRESULT sq_pushstringf(HSQUIRRELVM v,const SQChar *s,...); SQUIRREL_API SQRESULT sq_vpushstringf(HSQUIRRELVM v,const SQChar *s,va_list l); SQUIRREL_API SQRESULT sq_getnativeclosurepointer(HSQUIRRELVM v,SQInteger idx,SQFUNCTION *f); SQUIRREL_API SQRESULT sq_arrayreserve(HSQUIRRELVM v,SQInteger idx,SQInteger newcap); +SQUIRREL_API void sq_newarrayex(HSQUIRRELVM v,SQInteger capacity); SQUIRREL_API SQInteger sq_cmpr(HSQUIRRELVM v); #ifdef __cplusplus diff --git a/vendor/Squirrel/sqapiex.cpp b/vendor/Squirrel/sqapiex.cpp index 5c194e69..e0dd4ee6 100644 --- a/vendor/Squirrel/sqapiex.cpp +++ b/vendor/Squirrel/sqapiex.cpp @@ -120,6 +120,13 @@ SQRESULT sq_arrayreserve(HSQUIRRELVM v,SQInteger idx,SQInteger newcap) return sq_throwerror(v,_SC("negative capacity")); } +void sq_newarrayex(HSQUIRRELVM v,SQInteger capacity) +{ + SQArray* a = SQArray::Create(_ss(v), 0); + a->Reserve(capacity); + v->Push(a); +} + SQInteger sq_cmpr(HSQUIRRELVM v) { SQInteger res;