Structs like LoadedDevice, LoadedSbi, LoadedRole, LoadedUser are never passed as pointer
Problem Statement
While looking into another issue (#230 (closed)) I noticed that we never pass structs of types LoadedDevice, LoadedSbi, LoadedRole, LoadedUser as pointers, but always pass the entire struct. Especially concerning slices, we should reconsider whether pointers might not be useful there.
Benefits and risks
Regarding the topic, opinions differ a bit:
- Some argue pointers are faster and make it easier to work on slices (especially if you want to make changes to the elements in a slice) [1]
- Others say slices of structs are superior in every aspect [2]
Maybe we should decide for us how we would like to handle it.
[1] https://www.weinertworks.com/2018/12/31/golang-use-pointers-in-slices.html
[2] https://philpearl.github.io/post/bad_go_slice_of_pointers/
Proposed solution
Change at least the Get and GetAll methods of Stores to return pointers
Priority/Severity
-
High (This will bring a huge increase in performance/productivity/usability/legislative cover) -
Medium (This will bring a good increase in performance/productivity/usability) -
Low (anything else e.g., trivial, minor improvements)
Edited by Malte Bauch