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>2011-08-11 10:06:17 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-08-11 10:06:17 +0400
commita7663cc37753abd97744b51739358fb6b8026883 (patch)
tree5fe4e6bd695d42f47027c40c630f918bdec33294 /source/blender/python/intern/bpy_operator.c
parent0fac849d44d5bf8f2d3add9e10c03adbe5ffe331 (diff)
use ghash for operator and menu types, was doing string lookup in the operator list (containing over 1000 items) for each button draw.
gives small speedup for UI drawing and overall startup time.
Diffstat (limited to 'source/blender/python/intern/bpy_operator.c')
-rw-r--r--source/blender/python/intern/bpy_operator.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index 4b05a9c0c72..7310878f661 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -52,6 +52,9 @@
#include "WM_types.h"
#include "MEM_guardedalloc.h"
+
+#include "BLI_ghash.h"
+
#include "BKE_report.h"
#include "BKE_context.h"
@@ -359,15 +362,18 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
static PyObject *pyop_dir(PyObject *UNUSED(self))
{
+ GHashIterator *iter= WM_operatortype_iter();
PyObject *list= PyList_New(0), *name;
- wmOperatorType *ot;
-
- for(ot= WM_operatortype_first(); ot; ot= ot->next) {
+
+ for( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
+ wmOperatorType *ot= BLI_ghashIterator_getValue(iter);
+
name= PyUnicode_FromString(ot->idname);
PyList_Append(list, name);
Py_DECREF(name);
}
-
+ BLI_ghashIterator_free(iter);
+
return list;
}