PyAPI: minor optimization for dictionary creation
Pass size when its known.
This commit is contained in:
@@ -581,7 +581,7 @@ static PyObject *bpy_slot_to_py(BMesh *bm, BMOpSlot *slot)
|
||||
switch (slot->slot_subtype.map) {
|
||||
case BMO_OP_SLOT_SUBTYPE_MAP_ELEM:
|
||||
{
|
||||
item = PyDict_New();
|
||||
item = _PyDict_NewPresized(slot_hash ? BLI_ghash_size(slot_hash) : 0);
|
||||
if (slot_hash) {
|
||||
GHASH_ITER (hash_iter, slot_hash) {
|
||||
BMHeader *ele_key = BLI_ghashIterator_getKey(&hash_iter);
|
||||
@@ -599,7 +599,7 @@ static PyObject *bpy_slot_to_py(BMesh *bm, BMOpSlot *slot)
|
||||
}
|
||||
case BMO_OP_SLOT_SUBTYPE_MAP_FLT:
|
||||
{
|
||||
item = PyDict_New();
|
||||
item = _PyDict_NewPresized(slot_hash ? BLI_ghash_size(slot_hash) : 0);
|
||||
if (slot_hash) {
|
||||
GHASH_ITER (hash_iter, slot_hash) {
|
||||
BMHeader *ele_key = BLI_ghashIterator_getKey(&hash_iter);
|
||||
@@ -617,7 +617,7 @@ static PyObject *bpy_slot_to_py(BMesh *bm, BMOpSlot *slot)
|
||||
}
|
||||
case BMO_OP_SLOT_SUBTYPE_MAP_INT:
|
||||
{
|
||||
item = PyDict_New();
|
||||
item = _PyDict_NewPresized(slot_hash ? BLI_ghash_size(slot_hash) : 0);
|
||||
if (slot_hash) {
|
||||
GHASH_ITER (hash_iter, slot_hash) {
|
||||
BMHeader *ele_key = BLI_ghashIterator_getKey(&hash_iter);
|
||||
@@ -635,7 +635,7 @@ static PyObject *bpy_slot_to_py(BMesh *bm, BMOpSlot *slot)
|
||||
}
|
||||
case BMO_OP_SLOT_SUBTYPE_MAP_BOOL:
|
||||
{
|
||||
item = PyDict_New();
|
||||
item = _PyDict_NewPresized(slot_hash ? BLI_ghash_size(slot_hash) : 0);
|
||||
if (slot_hash) {
|
||||
GHASH_ITER (hash_iter, slot_hash) {
|
||||
BMHeader *ele_key = BLI_ghashIterator_getKey(&hash_iter);
|
||||
|
Reference in New Issue
Block a user