|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-07-11 06:55:16
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.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk