Changeset 1276 for branches/0.9-stable


Ignore:
Timestamp:
Nov 5, 2010, 1:24:26 PM (13 years ago)
Author:
Peter Johansson
Message:

Let Graph class hold information about last point (rev_max_) rather
than defining via the size of Vector. Not resizing the Vectors means
we can avoid some copying in Stats class. But it also means we need to
handle the case of empty Vector in Stats::max_element. Made the
function Node::svn_info(void) public. In svndigest.cc set rev_min also
when not using dates as well as setting the new static variable rev_max.
closes #485

Location:
branches/0.9-stable
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/0.9-stable/bin/svndigest.cc

    r1272 r1276  
    4444#include "yat/OptionArg.h"
    4545
     46#include <algorithm>
    4647#include <cassert>
    4748#include <cstdlib>
     
    203204
    204205
    205 void set_dates(const svndigest::SVNlog& log, svn_revnum_t last_rev)
    206 {
    207   assert(!log.commits().empty());
    208   // all plots uses the same xmin
    209   Graph::rev_min(log.commits().begin()->revision());
    210 
     206void set_dates(const svndigest::SVNlog& log)
     207{
    211208  // Fill in dates for revisions in log.
    212   std::vector<time_t> dates(last_rev+1, 0);
     209  std::vector<time_t> dates(log.latest_commit().revision()+1, 0);
    213210  for (SVNlog::container::const_iterator iter=log.commits().begin();
    214211       iter!=log.commits().end(); ++iter) {
     
    240237  }
    241238 
     239  if (option.verbose())
     240    std::cout << "Retrieving log information" << std::endl;
     241  assert(!tree.log().commits().empty());
     242  Graph::rev_min(tree.log().commits().begin()->revision());
     243  Graph::rev_max(tree.log().latest_commit().revision());
    242244  if (!option.revisions()) {
    243     if (option.verbose())
    244       std::cout << "Retrieving dates" << std::endl;
    245     // Note that last_changed_rev might be larger than lastest rev in log
    246     set_dates(tree.log(), tree.last_changed_rev());
     245    set_dates(tree.log());
    247246  }
    248247
  • branches/0.9-stable/lib/AddStats.cc

    r1194 r1276  
    103103  unsigned int AddStats::max_element(const SumVector& v) const
    104104  {
    105     assert(v.size());
     105    if (v.size()==0)
     106      return 0;
    106107    return v.back();
    107108  }
  • branches/0.9-stable/lib/ClassicStats.cc

    r1194 r1276  
    8181  ClassicStats::max_element(const SumVector& v) const
    8282  {
    83     assert(v.size());
     83    if (v.size()==0)
     84      return 0;
    8485    return v.back();
    8586  }
  • branches/0.9-stable/lib/Graph.cc

    r1275 r1276  
    3232namespace svndigest {
    3333
     34  svn_revnum_t Graph::rev_max_=0;
    3435  svn_revnum_t Graph::rev_min_=0;
    3536  std::vector<time_t> Graph::xticks_;
     
    9394      assert(!date_xticks() || rev_min_<xticks_.size());
    9495      assert(!date_xticks() || xticks_[rev_min_]);
    95       xmin_= date_xticks() ? xticks_[rev_min_] : 0;
    96       xmax_= date_xticks() ? xticks_.back() : y.size();
     96      assert(rev_min_<xticks_.size() || !date_xticks());
     97      xmin_= date_xticks() ? xticks_[rev_min_] : rev_min_;
     98      assert(rev_max_<xticks_.size() || !date_xticks());
     99      xmax_= date_xticks() ? xticks_[rev_max_] : rev_max_;
    97100      xrange_=xmax_-xmin_;
    98101      yrange_=ymax_-ymin_;
     
    126129      y0 = iter->second;
    127130    }
    128     svn_revnum_t xlast=date_xticks() ? xticks_.size() : y.size();
    129     --xlast;
    130     staircase(x0, y0, xlast, y0);
     131    staircase(x0, y0, rev_max_, y0);
    131132
    132133    legend_data legend;
     
    166167
    167168
     169  void Graph::rev_max(svn_revnum_t rev)
     170  {
     171    rev_max_ = rev;
     172  }
     173
     174
    168175  void Graph::rev_min(svn_revnum_t rev)
    169176  {
  • branches/0.9-stable/lib/Graph.h

    r1255 r1276  
    100100
    101101    /**
     102       Sets the right end of xrange to correspond to revision \a rev.
     103     */
     104    static void rev_max(svn_revnum_t rev);
     105
     106    /**
    102107       Sets the left end of xrange to correspond to revision \a rev.
    103108     */
     
    152157    plstream pls_;
    153158    static svn_revnum_t rev_min_;
     159    static svn_revnum_t rev_max_;
    154160    std::string timeformat_;
    155161    std::string title_;
  • branches/0.9-stable/lib/Node.h

    r1264 r1276  
    207207    std::string url(void) const;
    208208   
     209    inline const SVNinfo& svn_info(void) const { return svninfo_; }
     210
    209211  protected:
    210212    ///
     
    212214    ///
    213215    void path_anchor(std::ostream& os) const;
    214 
    215     inline const SVNinfo& svn_info(void) const { return svninfo_; }
    216216
    217217    unsigned int level_;
  • branches/0.9-stable/lib/Stats.cc

    r1255 r1276  
    440440    assert(stat->size());
    441441    assert(stat->find("all")!=stat->end());
    442     // FIXME: try keep a const& to avoid copying
    443     SumVector total=get_vector(*stat, "all");   
    444     total.resize(revision()+1);
     442    const SumVector& total=get_vector(*stat, "all");   
    445443    double yrange_max=1.03 * max_element(total) +1.0;
    446444    gp.ymax(yrange_max);
     
    452450         i != authors_.end(); ++i) {
    453451      assert(stat->find(*i)!=stat->end());
    454       // FIXME: avoid this copying?
    455       SumVector vec = get_vector(*stat,*i);
    456       vec.resize(revision()+1);
     452      const SumVector& vec = get_vector(*stat,*i);
    457453      if (max_element(vec)) {
    458454        author_cont.push_back(std::make_pair(*i,vec));
Note: See TracChangeset for help on using the changeset viewer.