Modify all places that use the Options structure to be a const
reference. The underlying structure is a u32 so making it a
reference doesn't really do anything. However, if the structure
changes in the future it already works and avoids future coders
wondering why a structure is being passed by value. This also
makes it clear that the Options should not be modified in those functions.
Details
- Reviewers
Chia-hungDuan - Commits
- rG867f2d9e5c9a: [scudo] Make Options a reference for functions.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Remove the const Options &Options = Options.load();
That's too aggressive and there is already a copy.
Just did a quick look on the type Options, it's a wrapper of AtomicOptions which contains a single atomic_32 data member. The change may make it require 64 bits space. If we want to assume that Options will be extended then passing by reference shows more value here. (Or maybe I misunderstand something here) I agree that making it passing by reference may be reasonable in terms of software architecture. No strong opinion here, will leave you to do the final decision.
Yeah, I was thinking about this and it doesn't do much. However, I do think the const is useful just to make sure the compiler catches any places where we try to modify the value. And even though making it a reference doesn't really do anything, it also prevents people from coming along and asking why a structure is being passed on the stack.
So I think it's reasonable to leave this as is, but I changed the description to be clearer about this.