Return-Path: X-Original-To: apmail-mesos-reviews-archive@minotaur.apache.org Delivered-To: apmail-mesos-reviews-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DDBB518C94 for ; Wed, 23 Sep 2015 00:58:55 +0000 (UTC) Received: (qmail 48975 invoked by uid 500); 23 Sep 2015 00:58:55 -0000 Delivered-To: apmail-mesos-reviews-archive@mesos.apache.org Received: (qmail 48949 invoked by uid 500); 23 Sep 2015 00:58:55 -0000 Mailing-List: contact reviews-help@mesos.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: reviews@mesos.apache.org Delivered-To: mailing list reviews@mesos.apache.org Received: (qmail 48930 invoked by uid 99); 23 Sep 2015 00:58:55 -0000 Received: from reviews-vm.apache.org (HELO reviews.apache.org) (140.211.11.40) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Sep 2015 00:58:55 +0000 Received: from reviews.apache.org (localhost [127.0.0.1]) by reviews.apache.org (Postfix) with ESMTP id 6B8E6285CAF; Wed, 23 Sep 2015 00:58:53 +0000 (UTC) Content-Type: multipart/alternative; boundary="===============1666614819163401436==" MIME-Version: 1.0 Subject: Re: Review Request 38158: Refactored Value::Ranges coalesce(). From: "Michael Park" To: "Joris Van Remoortere" , "Till Toenshoff" , "Bernd Mathiske" Cc: "Michael Park" , "Joerg Schad" , "mesos" Date: Wed, 23 Sep 2015 00:58:53 -0000 Message-ID: <20150923005853.31021.78460@reviews.apache.org> X-ReviewBoard-URL: https://reviews.apache.org/ Auto-Submitted: auto-generated Sender: "Michael Park" X-ReviewGroup: mesos X-Auto-Response-Suppress: DR, RN, OOF, AutoReply X-ReviewRequest-URL: https://reviews.apache.org/r/38158/ X-Sender: "Michael Park" References: <20150922205554.24659.45168@reviews.apache.org> In-Reply-To: <20150922205554.24659.45168@reviews.apache.org> Reply-To: "Michael Park" X-ReviewRequest-Repository: mesos --===============1666614819163401436== MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit ----------------------------------------------------------- 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) `s/operator<< (/operator<<(` src/common/values.cpp (line 109) `s/protbuf/protobuf/` src/common/values.cpp (line 111) Why not pass by value? src/common/values.cpp (lines 122 - 123) How about `return std::tie(lhs.start, lhs.end) < std::tie(rhs.start, rhs.end);`? src/common/values.cpp (lines 129 - 130) How about `Range current = ranges.front();`, and using `current.{start,end}` rather than `current{Start,End}`? src/common/values.cpp (lines 155 - 156) `ranges[count - 1] = current;` if you take the above suggestion. src/common/values.cpp (lines 158 - 159) `current = range;` if you take the above suggestion. src/common/values.cpp (lines 170 - 186) 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) Can we just take a `Value::Ranges` here rather than `initializer_list`? 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 > > --===============1666614819163401436==--