monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Monotone-devel] speed of "mtn ls branches"


From: William Uther
Subject: Re: [Monotone-devel] speed of "mtn ls branches"
Date: Fri, 18 Jan 2008 10:42:33 +1100


On 18/01/2008, at 8:59 AM, Zack Weinberg wrote:


On Jan 17, 2008 4:23 PM, William Uther
<address@hidden> wrote:
On 18/01/2008, at 4:15 AM, Zack Weinberg wrote:
update.cc, function calculate_update_set:

...
  bool have_non_suspended_rev = false;

for (set<revision_id>::const_iterator it = candidates.begin(); it !=
candidates.end(); it++)
    {
      if (!app.get_project().revision_is_suspended_in_branch(*it,
branch))
        {
          have_non_suspended_rev = true;
          break;
        }
    }
  if (!app.opts.ignore_suspend_certs && have_non_suspended_rev)
    {
      // remove all suspended revisions
      base64<cert_value> branch_encoded;
      encode_base64(cert_value(branch()), branch_encoded);
      suspended_in_branch s(app, branch_encoded);
for(std::set<revision_id>::iterator it = candidates.begin (); it
!= candidates.end(); it++)
        if (s(*it))
          candidates.erase(*it);
    }

Yes, that is repeating some work.  Here is the intention:

   If there are any non-suspended update candidates then remove the
suspended
   update candidates, otherwise leave all the suspended revs in the
candidate
   set.

Couldn't you do that like this?  (note: the code under discussion is
the last thing in the function, and "candidates" is its out-argument).

    if (app.opts.ignore_suspend_certs)
      return;

    set<revision_id> active_candidates;
    for (set<revision_id>::const_iterator i = candidates.begin();
         i != candidates.end(); i++)
if (!app.get_project().revision_is_suspended_in_branch(*i, branch))
        active_candidates.push_back(*i);

    if (!active_candidates.empty())
      {
// maybe we could just do "candidates = active_candidates;" here?
        candidates.clear();
        std::copy(active_candidates.begin(), active_candidates.end(),
                  candidates);
      }

Yeah - that looks right.  I assume it passes the tests.  There are tests
on the correctness of this behaviour.

Cheers,

Will      :-}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]