----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/38158/#review100091 -----------------------------------------------------------
I've got some clean-up suggestions, I think `lhs` and `rhs` variables should be renamed to `result` and `source` or something along those lines. src/common/values.cpp (line 45) <https://reviews.apache.org/r/38158/#comment157195> `s/operator<< (/operator<<(` src/common/values.cpp (line 109) <https://reviews.apache.org/r/38158/#comment157206> `s/protbuf/protobuf/` src/common/values.cpp (line 111) <https://reviews.apache.org/r/38158/#comment157207> Why not pass by value? src/common/values.cpp (lines 122 - 123) <https://reviews.apache.org/r/38158/#comment157211> How about `return std::tie(lhs.start, lhs.end) < std::tie(rhs.start, rhs.end);`? src/common/values.cpp (lines 129 - 130) <https://reviews.apache.org/r/38158/#comment157216> How about `Range current = ranges.front();`, and using `current.{start,end}` rather than `current{Start,End}`? src/common/values.cpp (lines 155 - 156) <https://reviews.apache.org/r/38158/#comment157218> `ranges[count - 1] = current;` if you take the above suggestion. src/common/values.cpp (lines 158 - 159) <https://reviews.apache.org/r/38158/#comment157217> `current = range;` if you take the above suggestion. src/common/values.cpp (lines 170 - 186) <https://reviews.apache.org/r/38158/#comment157230> Could we simply `Resize` and not worry about `DeleteSubrange`, `Reserve`, and `add_range`? ```cpp result->mutable_range()->Resize(count, {}); ``` src/common/values.cpp (line 198) <https://reviews.apache.org/r/38158/#comment157231> Can we just take a `Value::Ranges` here rather than `initializer_list<Value::Ranges>`? It looks like the only place we actually use this is in `operator+`, for which we can just follow the pattern for `operator-`. ```cpp coalesce(&result, left); return result += result; ``` I think it would also clean up this code significantly, as we wouldn't need the `rangesSum` loop, The `fill` function wouldn't have to be factored out, wouldn't need the `offset` math, etc. - Michael Park On Sept. 22, 2015, 8:55 p.m., Joerg Schad wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/38158/ > ----------------------------------------------------------- > > (Updated Sept. 22, 2015, 8:55 p.m.) > > > Review request for mesos, Bernd Mathiske, Joris Van Remoortere, and Till > Toenshoff. > > > Bugs: MESOS-3051 > https://issues.apache.org/jira/browse/MESOS-3051 > > > Repository: mesos > > > Description > ------- > > The goal of this refactoring was to reuse the Ranges objects as much as > possible, as prior there was substantial time spend in allocation/destruction > (MESOS-3051). > > > Diffs > ----- > > src/common/values.cpp 750264e603b4cde2011f07f4434a4b34fe3e512f > src/tests/resources_tests.cpp 0318885336409f7cc9dbd4a3daa9b52db197bbd1 > src/tests/values_tests.cpp fc35d97894a2de6207b9337180e2160e6f2cb1f5 > > Diff: https://reviews.apache.org/r/38158/diff/ > > > Testing > ------- > > make check > > > Thanks, > > Joerg Schad > >