RNA: Don't allocate empty char pointer properties
Instead of allocating a single 0 char, set the `char *` DNA pointer to null. This avoids the overhead of allocating and copying single-bytes. rBeed45b655c9f didn't do this for safety reasons, but I checked the existing uses of this behavior in DNA/RNA. Out of 43 total `char *` members, this change only affects 7 recently added properties. For a complete list, see the patch description. Differential Revision: https://developer.blender.org/D14779
This commit is contained in:
parent
c771dd5e9c
commit
35b4e3a350
|
@ -1117,8 +1117,10 @@ static char *rna_def_property_set_func(
|
|||
fprintf(
|
||||
f, " if (data->%s != NULL) { MEM_freeN(data->%s); }\n", dp->dnaname, dp->dnaname);
|
||||
fprintf(f, " const int length = strlen(value);\n");
|
||||
fprintf(f, " data->%s = MEM_mallocN(length + 1, __func__);\n", dp->dnaname);
|
||||
fprintf(f, " %s(data->%s, value, length + 1);\n", string_copy_func, dp->dnaname);
|
||||
fprintf(f, " if (length > 0) {\n");
|
||||
fprintf(f, " data->%s = MEM_mallocN(length + 1, __func__);\n", dp->dnaname);
|
||||
fprintf(f, " %s(data->%s, value, length + 1);\n", string_copy_func, dp->dnaname);
|
||||
fprintf(f, " } else { data->%s = NULL; }\n", dp->dnaname);
|
||||
}
|
||||
else {
|
||||
/* Handle char array properties. */
|
||||
|
|
Loading…
Reference in New Issue