DECLARE_DYNAMIC_MULTICAST_DELEGATE why passing parameters by value?


Why some of the parameters in delegate signatures are passed by value, not by reference?

For example

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams( FActorHitSignature, AActor*, SelfActor, AActor*, OtherActor, FVector, NormalImpulse, const FHitResult&, Hit );

Hit can be passed by reference, SelfActor is passed by pointer, but for some reason NormalImpulse isn’t passed by reference?
Why? If I rememeber correctly passing parameter to function as reference/pointer is much faster than by value.



It’s faster only if the structure is extremely slow to copy. In this case, FVector is a mere 12 bytes, and it may well be faster to put it on the stack just to avoid cache misses.

More practically, the bottleneck for actor collisions is never going to be the cost of passing an FVector. Across all games written in UE4, for the entire history of the human race, the total CPU time spent copying that FVector will be less than the time I spent writing this response.