
11 Jul
2004
11 Jul
'04
11:55 a.m.
John Maddock wrote: [...]
template <class T> void fill_n(T* data, int len, call_traits<T>::call_type val) { while(len) { data[len--] == val; // if val is a reference it gets re-loaded every time rather than cached in a register } }
fill_n should just take val by value. There are "len" assignments in the loop; the additional cost of one copy is insignificant. No point on relying on heuristics here.