Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2016-07-31 10:22:04 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-07-31 10:22:04 +0300
commita96c9def6f57269f6ff10a189cd55ff43dc3a15f (patch)
tree39e868feff4d58deadf062627d2ece40c8bc25db /source/blender/python
parente97ab8347a16f84bdddeaf53305cd9a7f42860ab (diff)
PyAPI: minor optimization for dictionary creation
Pass size when its known.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/bmesh/bmesh_py_ops_call.c8
-rw-r--r--source/blender/python/generic/idprop_py_api.c2
-rw-r--r--source/blender/python/intern/bpy_app_translations.c2
-rw-r--r--source/blender/python/intern/bpy_driver.c2
-rw-r--r--source/blender/python/intern/bpy_library_load.c4
-rw-r--r--source/blender/python/intern/bpy_rna_id_collection.c2
6 files changed, 10 insertions, 10 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_ops_call.c b/source/blender/python/bmesh/bmesh_py_ops_call.c
index 551a66d1ed8..8f287918a4a 100644
--- a/source/blender/python/bmesh/bmesh_py_ops_call.c
+++ b/source/blender/python/bmesh/bmesh_py_ops_call.c
@@ -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);
diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c
index 2f8afdf1ed1..2e15b7b1413 100644
--- a/source/blender/python/generic/idprop_py_api.c
+++ b/source/blender/python/generic/idprop_py_api.c
@@ -688,7 +688,7 @@ static PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
}
case IDP_GROUP:
{
- PyObject *dict = PyDict_New();
+ PyObject *dict = _PyDict_NewPresized(prop->len);
IDProperty *loop;
for (loop = prop->data.group.first; loop; loop = loop->next) {
diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c
index b90deafb377..6ba858f0228 100644
--- a/source/blender/python/intern/bpy_app_translations.c
+++ b/source/blender/python/intern/bpy_app_translations.c
@@ -675,7 +675,7 @@ static PyObject *app_translations_new(PyTypeObject *type, PyObject *UNUSED(args)
_translations->contexts = app_translations_contexts_make();
- py_ctxts = PyDict_New();
+ py_ctxts = _PyDict_NewPresized(ARRAY_SIZE(_contexts));
for (ctxt = _contexts; ctxt->c_id; ctxt++) {
PyObject *val = PyUnicode_FromString(ctxt->py_id);
PyDict_SetItemString(py_ctxts, ctxt->c_id, val);
diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c
index a03c50d8c90..c8ce7b2f770 100644
--- a/source/blender/python/intern/bpy_driver.c
+++ b/source/blender/python/intern/bpy_driver.c
@@ -293,7 +293,7 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, ChannelDriver *driver, c
}
/* add target values to a dict that will be used as '__locals__' dict */
- driver_vars = PyDict_New();
+ driver_vars = _PyDict_NewPresized(PyTuple_GET_SIZE(expr_vars));
for (dvar = driver->variables.first, i = 0; dvar; dvar = dvar->next) {
PyObject *driver_arg = NULL;
diff --git a/source/blender/python/intern/bpy_library_load.c b/source/blender/python/intern/bpy_library_load.c
index 37a7e0e23dd..ec69abbb1df 100644
--- a/source/blender/python/intern/bpy_library_load.c
+++ b/source/blender/python/intern/bpy_library_load.c
@@ -210,7 +210,7 @@ static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject *
ret->flag = ((is_link ? FILE_LINK : 0) |
(is_rel ? FILE_RELPATH : 0));
- ret->dict = PyDict_New();
+ ret->dict = _PyDict_NewPresized(MAX_LIBARRAY);
return (PyObject *)ret;
}
@@ -240,7 +240,7 @@ static PyObject *bpy_lib_enter(BPy_Library *self, PyObject *UNUSED(args))
{
PyObject *ret;
BPy_Library *self_from;
- PyObject *from_dict = PyDict_New();
+ PyObject *from_dict = _PyDict_NewPresized(MAX_LIBARRAY);
ReportList reports;
BKE_reports_init(&reports, RPT_STORE);
diff --git a/source/blender/python/intern/bpy_rna_id_collection.c b/source/blender/python/intern/bpy_rna_id_collection.c
index 104e3e47646..31189ba4dee 100644
--- a/source/blender/python/intern/bpy_rna_id_collection.c
+++ b/source/blender/python/intern/bpy_rna_id_collection.c
@@ -198,7 +198,7 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject *
PyObject **subset_array = PySequence_Fast_ITEMS(subset_fast);
Py_ssize_t subset_len = PySequence_Fast_GET_SIZE(subset_fast);
- data_cb.user_map = PyDict_New();
+ data_cb.user_map = _PyDict_NewPresized(subset_len);
data_cb.is_subset = true;
for (; subset_len; subset_array++, subset_len--) {
PyObject *set = PySet_New(NULL);