expose Vector->reserve(size) to php space
example usage: genv() takes a Vector of Awaitable and creates a Vector of WaitHandles. resize() requires a default value, reserve allows us to hint proper allocation.
Esse commit está contido em:
@@ -256,6 +256,21 @@ void c_Vector::t_resize(CVarRef sz, CVarRef value) {
|
||||
resize(intSz, val);
|
||||
}
|
||||
|
||||
void c_Vector::t_reserve(CVarRef sz) {
|
||||
if (!sz.isInteger()) {
|
||||
Object e(SystemLib::AllocInvalidArgumentExceptionObject(
|
||||
"Parameter sz must be a non-negative integer"));
|
||||
throw e;
|
||||
}
|
||||
int64_t intSz = sz.toInt64();
|
||||
if (intSz < 0) {
|
||||
Object e(SystemLib::AllocInvalidArgumentExceptionObject(
|
||||
"Parameter sz must be a non-negative integer"));
|
||||
throw e;
|
||||
}
|
||||
reserve(intSz);
|
||||
}
|
||||
|
||||
Object c_Vector::t_clear() {
|
||||
++m_version;
|
||||
uint sz = m_size;
|
||||
|
||||
@@ -46,6 +46,7 @@ class c_Vector : public ExtObjectDataFlags<ObjectData::VectorAttrInit|
|
||||
Object t_append(CVarRef val); // deprecated
|
||||
Variant t_pop();
|
||||
void t_resize(CVarRef sz, CVarRef value);
|
||||
void t_reserve(CVarRef sz);
|
||||
Object t_clear();
|
||||
bool t_isempty();
|
||||
int64_t t_count();
|
||||
|
||||
@@ -331,6 +331,21 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "reserve",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"return": {
|
||||
"type": null
|
||||
},
|
||||
"args": [
|
||||
{
|
||||
"name": "sz",
|
||||
"type": "Variant"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "toArray",
|
||||
"flags": [
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário