C++ RNA: Pass structures by reference
authorSergey Sharybin <sergey.vfx@gmail.com>
Sat, 28 Nov 2015 16:20:30 +0000 (21:20 +0500)
committerSergey Sharybin <sergey.vfx@gmail.com>
Sat, 28 Nov 2015 16:20:30 +0000 (21:20 +0500)
C++ structures might be rather big and passing them by value is not really
optimal. There should be no functional changes apart from better memory
access pattern when synchronizing huge scenes to Cycles.

source/blender/makesrna/intern/makesrna.c

index 887124fc48655d39fb25b239342321f9eec9b042..ce977daf30a3863f1f5ab8f5290cbe8cab429e91 100644 (file)
@@ -1900,9 +1900,13 @@ static void rna_def_struct_function_prototype_cpp(FILE *f, StructRNA *UNUSED(srn
                if (!(flag & PROP_DYNAMIC) && dp->prop->arraydimension)
                        fprintf(f, "%s %s[%u]", rna_parameter_type_cpp_name(dp->prop),
                                rna_safe_id(dp->prop->identifier), dp->prop->totarraylength);
-               else
-                       fprintf(f, "%s %s%s", rna_parameter_type_cpp_name(dp->prop),
-                               ptrstr, rna_safe_id(dp->prop->identifier));
+               else {
+                       fprintf(f, "%s%s%s%s",
+                               rna_parameter_type_cpp_name(dp->prop),
+                               (dp->prop->type == PROP_POINTER && ptrstr[0] == '\0') ? "& " : " ",
+                               ptrstr,
+                               rna_safe_id(dp->prop->identifier));
+               }
        }
 
        fprintf(f, ")");