From a8e49cd55a9cb5ca43dfb3d97c4ad0968a469b45 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 1 Sep 2011 09:47:21 +0000 Subject: [PATCH] use a fixed 32byte buffer for getting an rna string from python. gives a slight speedup when drawing heavy UI's --- source/blender/python/intern/bpy_rna.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index e1c38a82142..6de3c040c18 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1298,7 +1298,9 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop) { int subtype= RNA_property_subtype(prop); const char *buf; - buf= RNA_property_string_get_alloc(ptr, prop, NULL, -1); + char buf_fixed[32]; + + buf= RNA_property_string_get_alloc(ptr, prop, buf_fixed, sizeof(buf_fixed)); #ifdef USE_STRING_COERCE /* only file paths get special treatment, they may contain non utf-8 chars */ if(ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) { @@ -1310,7 +1312,9 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop) #else // USE_STRING_COERCE ret= PyUnicode_FromString(buf); #endif // USE_STRING_COERCE - MEM_freeN((void *)buf); + if(buf_fixed != buf) { + MEM_freeN((void *)buf); + } break; } case PROP_ENUM: