Changeset 759


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

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/svndigest.cc

    r749 r759  
    166166      std::vector<std::string> dates;
    167167      dates.reserve(log.commits().size());
    168       for (size_t i=0; i<log.commits().size(); ++i) {
    169         assert(static_cast<svn_revnum_t>(i)==log.commits()[i].revision());
    170         dates.push_back(log.commits()[i].date());
     168      size_t rev = 0;
     169      for (SVNlog::container::const_iterator iter=log.commits().begin();
     170           iter!=log.commits().end(); ++iter) {
     171        assert(static_cast<svn_revnum_t>(rev)==iter->revision());
     172        assert(++rev);
     173        dates.push_back(iter->date());
    171174      }
    172       GnuplotFE::instance()->set_dates(dates);
    173175    }
    174176    if (chdir(option->targetdir().c_str()) ) {
  • trunk/lib/Node.cc

    r757 r759  
    7878      return svninfo_.last_changed_author();
    7979    assert(log().commits().size());
    80     return log().commits().back().author();
     80    return log().latest_commit().author();
    8181  }
    8282
     
    145145      return svninfo_.last_changed_rev();
    146146    assert(log().commits().size());
    147     return log().commits().back().revision();
     147    return log().latest_commit().revision();
    148148  }
    149149
     
    318318    std::map<int, svn_revnum_t> year2rev;
    319319    SVNlog log(path());
    320     typedef std::vector<Commitment>::const_iterator LogIterator;
    321     for (LogIterator i=log.commits().begin(); i<log.commits().end(); ++i){
     320    typedef SVNlog::container::const_iterator LogIterator;
     321    for (LogIterator i=log.commits().begin(); i!=log.commits().end(); ++i){
    322322      time_t sec = str2time(i->date());
    323323      tm* timeinfo = gmtime(&sec);
  • 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  }
  • trunk/lib/SVNlog.h

    r693 r759  
    2828
    2929#include <string>
    30 #include <vector>
     30#include <set>
    3131
    3232#include <subversion-1/svn_client.h>
     
    4444  class SVNlog {
    4545  public:
     46    /**
     47       container used to store log
     48     */
     49    typedef std::set<Commitment, LessRevision> container;
     50
    4651    /**
    4752       Default constructor. Creates empty log.
     
    6570       \return Commitments
    6671    */
    67     inline const std::vector<Commitment>& commits(void) const
     72    inline const container& commits(void) const
    6873    { return lb_.commits; }
    6974
     
    7176       \return Commitments
    7277    */
    73     inline std::vector<Commitment>& commits(void)
     78    inline container& commits(void)
    7479    { return lb_.commits; }
    7580
     
    110115    */
    111116    struct log_receiver_baton {
    112       std::vector<Commitment> commits;
     117      container commits;
    113118    } lb_;
    114119
  • trunk/lib/first_page.cc

    r751 r759  
    8484  {
    8585    assert(log.commits().size());
    86     Date begin(log.commits()[0].date());
    87     Date end(log.commits().back().date());
     86    Date begin(log.commits().begin()->date());   
     87    Date end(log.latest_commit().date());
    8888    std::string timefmt("%a %b %e %H:%M:%S %Y");
    8989
     
    102102    os << end.difftime(begin);
    103103    os << "</td></tr>\n"
    104        << "<tr><td>Smallest Revision:</td><td>" << log.commits()[0].revision()
    105        << "</td></tr>\n"
    106        << "<tr><td>Largest Revision:</td><td>" <<log.commits().back().revision()
     104       << "<tr><td>Smallest Revision:</td><td>"
     105       << log.commits().begin()->revision()
     106       << "</td></tr>\n"
     107       << "<tr><td>Largest Revision:</td><td>" << log.latest_commit().revision()
    107108       << "</td></tr>\n"
    108109       << "<tr><td>Revision Count:</td><td>" << log.commits().size()
     
    175176    const size_t maxlength = 80;
    176177    const Configuration& conf = Configuration::instance();
    177     typedef std::vector<Commitment>::const_reverse_iterator iter;
     178    typedef SVNlog::container::const_reverse_iterator iter;
     179    size_t count = 0;
    178180    for (iter i=log.commits().rbegin();
    179          i < std::min(log.commits().rbegin()+10,log.commits().rend()); ++i) {
     181         i != log.commits().rend() && count<10; ++i) {
    180182      os << "<tr><td>"
    181183         << anchor(std::string("classic/")+i->author()+"/total/index.html",
     
    216218
    217219      os << "</td></tr>\n";
     220      ++count;
    218221    }
    219222    os << "</table></div>\n";
Note: See TracChangeset for help on using the changeset viewer.