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>2014-01-20 11:03:23 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-01-20 11:09:00 +0400
commita696a0ff1e9c55c21696c18a6cf6e5b1b2a40e37 (patch)
treec9dba903b0a90fddae6375131140bcad58d69859 /source/blender/python/intern/bpy_intern_string.c
parentece504aff8ed3777498c459d5ce618f99be4df6e (diff)
Python API: create args for meta-classes directly (a little faster).
Also add some new interned strings.
Diffstat (limited to 'source/blender/python/intern/bpy_intern_string.c')
-rw-r--r--source/blender/python/intern/bpy_intern_string.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/source/blender/python/intern/bpy_intern_string.c b/source/blender/python/intern/bpy_intern_string.c
index 294f230ce99..9c93af1786c 100644
--- a/source/blender/python/intern/bpy_intern_string.c
+++ b/source/blender/python/intern/bpy_intern_string.c
@@ -32,38 +32,50 @@
#include "bpy_intern_string.h"
+#include "BLI_utildefines.h"
+
+static PyObject *bpy_intern_str_arr[11];
+
PyObject *bpy_intern_str_register;
PyObject *bpy_intern_str_unregister;
PyObject *bpy_intern_str_bl_rna;
PyObject *bpy_intern_str_bl_property;
+PyObject *bpy_intern_str_bpy_types;
PyObject *bpy_intern_str_order;
PyObject *bpy_intern_str_attr;
PyObject *bpy_intern_str___slots__;
PyObject *bpy_intern_str___name__;
PyObject *bpy_intern_str___doc__;
+PyObject *bpy_intern_str___module__;
void bpy_intern_string_init(void)
{
- bpy_intern_str_register = PyUnicode_FromString("register");
- bpy_intern_str_unregister = PyUnicode_FromString("unregister");
- bpy_intern_str_bl_rna = PyUnicode_FromString("bl_rna");
- bpy_intern_str_bl_property = PyUnicode_FromString("bl_property");
- bpy_intern_str_order = PyUnicode_FromString("order");
- bpy_intern_str_attr = PyUnicode_FromString("attr");
- bpy_intern_str___slots__ = PyUnicode_FromString("__slots__");
- bpy_intern_str___name__ = PyUnicode_FromString("__name__");
- bpy_intern_str___doc__ = PyUnicode_FromString("__doc__");
+ unsigned int i = 0;
+
+#define BPY_INTERN_STR(var, str) \
+ { var = bpy_intern_str_arr[i++] = PyUnicode_FromString(str); } (void)0
+
+ BPY_INTERN_STR(bpy_intern_str_register, "register");
+ BPY_INTERN_STR(bpy_intern_str_unregister, "unregister");
+ BPY_INTERN_STR(bpy_intern_str_bl_rna, "bl_rna");
+ BPY_INTERN_STR(bpy_intern_str_bl_property, "bl_property");
+ BPY_INTERN_STR(bpy_intern_str_bpy_types, "bpy.types");
+ BPY_INTERN_STR(bpy_intern_str_order, "order");
+ BPY_INTERN_STR(bpy_intern_str_attr, "attr");
+ BPY_INTERN_STR(bpy_intern_str___slots__, "__slots__");
+ BPY_INTERN_STR(bpy_intern_str___name__, "__name__");
+ BPY_INTERN_STR(bpy_intern_str___doc__, "__doc__");
+ BPY_INTERN_STR(bpy_intern_str___module__, "__module__");
+
+#undef BPY_INTERN_STR
+
+ BLI_assert(i == (sizeof(bpy_intern_str_arr) / sizeof(*bpy_intern_str_arr)));
}
void bpy_intern_string_exit(void)
{
- Py_DECREF(bpy_intern_str_register);
- Py_DECREF(bpy_intern_str_unregister);
- Py_DECREF(bpy_intern_str_bl_rna);
- Py_DECREF(bpy_intern_str_bl_property);
- Py_DECREF(bpy_intern_str_order);
- Py_DECREF(bpy_intern_str_attr);
- Py_DECREF(bpy_intern_str___slots__);
- Py_DECREF(bpy_intern_str___name__);
- Py_DECREF(bpy_intern_str___doc__);
+ unsigned int i = sizeof(bpy_intern_str_arr) / sizeof(*bpy_intern_str_arr);
+ while (i--) {
+ Py_DECREF(bpy_intern_str_arr[i]);
+ }
}