Changeset 759 for trunk/lib/SVNlog.cc


Ignore:
Timestamp:
Jan 29, 2009, 12:51:35 PM (12 years ago)
Author:
Peter Johansson
Message:

Change container in SVNlog to be std::set<Commitment>, in order to
avoid copying in SVNlog::operator+=. Previously we had vector, but the
index had no meaning, in other words, the random access was not used.

refs #74

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/SVNlog.cc

    r756 r759  
    3030#include <sstream>
    3131#include <string>
    32 #include <vector>
    3332
    3433namespace theplu {
     
    5655  {
    5756   
    58     std::vector<Commitment>::const_reverse_iterator iter = commits().rbegin();
     57    SVNlog::container::const_reverse_iterator iter = commits().rbegin();
    5958    for ( ; iter!= commits().rend(); ++iter)
    6059      if (iter->author() == name)
     
    6766  {
    6867    assert(commits().size());
    69     return commits().back();
     68    return *commits().rbegin();
    7069  }
    7170
     
    7372  const Commitment& SVNlog::latest_commit(std::string name) const
    7473  {
    75     std::vector<Commitment>::const_reverse_iterator iter = commits().rbegin();
     74    SVNlog::container::const_reverse_iterator iter = commits().rbegin();
    7675    for ( ; iter!= commits().rend(); ++iter)
    7776      if (iter->author() == name)
     
    10099    if (msg)
    101100      message = msg;
    102     lb->commits.push_back(Commitment(a, date, message, rev));
     101    lb->commits.insert(lb->commits.end(), Commitment(a, date, message, rev));
    103102    return SVN_NO_ERROR;
    104103  }
     
    113112  SVNlog& operator+=(SVNlog& lhs, const SVNlog& rhs)
    114113  {
    115     SVNlog log;
    116     log.commits().reserve(std::max(lhs.commits().size(), rhs.commits().size()));
    117     std::set_union(lhs.commits().begin(), lhs.commits().end(),
    118                    rhs.commits().begin(), rhs.commits().end(),
    119                    std::back_inserter(log.commits()), LessRevision());
    120     lhs.swap(log);
     114    lhs.commits().insert(rhs.commits().begin(), rhs.commits().end());
    121115    return lhs;
    122116  }
Note: See TracChangeset for help on using the changeset viewer.