From 13d5a3af3fa097f03372eb319d7170412bb82fa1 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Sun, 15 Jul 2018 21:31:44 +0300 Subject: [PATCH] Introduce a new constructor into the sqrat Table wrapper which can create a table with an initial capacity. --- include/sqrat/sqratTable.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/sqrat/sqratTable.h b/include/sqrat/sqratTable.h index 1cc532bd..65e58b50 100644 --- a/include/sqrat/sqratTable.h +++ b/include/sqrat/sqratTable.h @@ -535,6 +535,20 @@ public: Table(HSQOBJECT o, HSQUIRRELVM v = DefaultVM::Get()) : TableBase(o, v) { } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// Construct the TableBase with an initial capacity + /// + /// \param v VM to create the Table in + /// \param c The initial capacity of the created table + /// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + Table(HSQUIRRELVM v, SQInteger c) : TableBase(v) { + sq_newtableex(vm, c); + sq_getstackobj(vm,-1,&obj); + sq_addref(vm, &obj); + sq_pop(vm,1); + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Copy constructor ///