Juce::Justification: Pass by Reference or Not


#1

Is there an advantage to passing a Justification object as a reference (see juce::GlyphArrangement) ? From what I understand, your coding standard suggests that the object is small enough that it should be pass-by-value.

So, the best-practice advice from the guys who actually write the optimisers is: Always stick to pass-by-value if possible, and only use references if the price of calling the copy constructor is very high.

 The class is wrapping an integer - "the price" can't be that high?


#2

Yes - definitely always pass a Justification object by value. I guess GlyphArrangement is just one that I missed!

(Although there will be a few places where a reference is used in a virtual method, and I don't want to break people's existing derived classes by changing the method signature)