use a fixed 32byte buffer for getting an rna string from python. gives a slight speed...
authorCampbell Barton <ideasman42@gmail.com>
Thu, 1 Sep 2011 09:47:21 +0000 (09:47 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 1 Sep 2011 09:47:21 +0000 (09:47 +0000)
source/blender/python/intern/bpy_rna.c

index e1c38a82142f580c0b9b903bff3e7283792c055e..6de3c040c18643749fa6d21d8a93eb7e6f2bc1ea 100644 (file)
@@ -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: