On 2020/01/31 17:38:55, Dan Eble wrote: > On 2020/01/30 23:22:46, hanwenn wrote: > > In the lily/ directory > > > > git grep 'vector<[^>]\+> &' *c|grep -v const > > > > returns 20 results, which is pretty small, given the number of methods in the > > code base. A cursory inspection suggests that Mike introduced most of these, > and > > I would have probably suggested to use pointers there too. I would also change > > these signatures if would stumble across them while refactoring something > else. > > Wouldn't this policy tend toward crimes against readability like the following? > > void twiddle_vector(vector<int> *vec) > { > if (!vec || vec->empty ()) > return; > > for (size_t i = 0; i < vec->size() - 1; ++i) > { > if ((*vec)[i] < 10) > (*vec)[i] = (*vec)[i] + 2 * (*vec)[i + 1]; > else > (*vec)[i] = (*vec)[i] * 2 - (*vec)[i + 1]; > } > } > > How would you approach that?
you can do a local alias vector<> &v = *vec; to aid readability. https://codereview.appspot.com/577410045/