bearophile wrote:
Bekenn:The use of ref introduces a level of indirection.This is correct. But a minimally decent compiler must be able to remove this indirection where possible, like here, and produce efficient code.
Having the optimizer remove indirection is rarely possible in C or C++, due to aliasing.