RNA: return PointerRNA from rna create functions

There are a couple of functions that create rna pointers. For example
`RNA_main_pointer_create` and `RNA_pointer_create`. Currently, those
take an output parameter `r_ptr` as last argument. This patch changes
it so that the functions actually return a` PointerRNA` instead of using
the output parameters.

This has a few benefits:
* Output parameters should only be used when there is an actual benefit.
  Otherwise, one should default to returning the value.
* It's simpler to use the API in the large majority of cases (note that this
  patch reduces the number of lines of code).
* It allows the `PointerRNA` to be const on the call-site, if that is desired.

No performance regression has been measured in production files.
If one of these functions happened to be called in a hot loop where
there is a regression, the solution should be to use an inline function
there which allows the compiler to optimize it even better.

Pull Request: https://projects.blender.org/blender/blender/pulls/111976
This commit is contained in:
Jacques Lucke
2023-09-06 00:48:50 +02:00
parent 8a3766e241
commit b5c89822ac
202 changed files with 841 additions and 1358 deletions

View File

@@ -65,8 +65,7 @@ static PyObject *Freestyle_getCurrentScene(PyObject * /*self*/)
PyErr_SetString(PyExc_TypeError, "current scene not available");
return nullptr;
}
PointerRNA ptr_scene;
RNA_pointer_create(&scene->id, &RNA_Scene, scene, &ptr_scene);
PointerRNA ptr_scene = RNA_pointer_create(&scene->id, &RNA_Scene, scene);
return pyrna_struct_CreatePyObject(&ptr_scene);
}