Changeset 1197 for trunk


Ignore:
Timestamp:
Oct 4, 2010, 6:32:09 AM (10 years ago)
Author:
Peter Johansson
Message:

convert date strings to int once in main rather than once for every plot

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/svndigest.cc

    r1186 r1197  
    2424#include "lib/Configuration.h"
    2525#include "lib/css.h"
     26#include "lib/Date.h"
    2627#include "lib/Directory.h"
    2728#include "lib/first_page.h"
     
    4243#include <cassert>
    4344#include <cstdlib>
     45#include <ctime>
    4446#include <iostream>
    4547#include <fstream>
     
    198200    std::cout << "Retrieving dates" << std::endl;
    199201  SVNlog log(repo);
    200   std::vector<std::string> dates;
     202  std::vector<time_t> dates;
    201203  dates.reserve(log.commits().size());
    202204  for (SVNlog::container::const_iterator iter=log.commits().begin();
    203205       iter!=log.commits().end(); ++iter) {
    204206    assert(static_cast<svn_revnum_t>(dates.size())==iter->revision());
    205     dates.push_back(iter->date());
     207    dates.push_back(Date(iter->date()).seconds());
    206208  }
    207209  // all plots uses the same dates
  • trunk/lib/File.cc

    r1186 r1197  
    268268    }
    269269    else {
    270       last = Date(Graph::xticks().back()).seconds();
     270      last = Graph::xticks().back();
    271271      // earliest date corresponds either to revision 0 or revision 1
    272       first = std::min(Date(Graph::xticks()[0]).seconds(),
    273                        Date(Graph::xticks()[1]).seconds());
     272      first = std::min(Graph::xticks()[0],Graph::xticks()[1]);
    274273    }
    275274    // color is calculated linearly on time, c = kt + m
  • trunk/lib/Graph.cc

    r1194 r1197  
    3232namespace svndigest {
    3333
    34   std::vector<std::string> Graph::xticks_;
     34  std::vector<time_t> Graph::xticks_;
    3535
    3636  Graph::Graph(const std::string& filename, const std::string& format)
     
    9191    if (!plots_) {
    9292      // date[0] is not the oldest when repo is imported with cvs2svn
    93       xmin_= date_xticks() ?
    94         std::min( Date(xticks_[0]), Date(xticks_[1]) ).seconds() : 0;
    95       xmax_= date_xticks() ? Date(xticks_.back()).seconds() : y.size();
     93      xmin_= date_xticks() ? std::min(xticks_[0], xticks_[1]) : 0;
     94      xmax_= date_xticks() ? xticks_.back() : y.size();
    9695      xrange_=xmax_-xmin_;
    9796      yrange_=ymax_-ymin_;
     
    121120      PLFLT x1=i;
    122121      if (date_xticks()) {
    123         x0=Date(xticks_[i-1]).seconds();
    124         x1=Date(xticks_[i]).seconds();
     122        x0=xticks_[i-1];
     123        x1=xticks_[i];
    125124      }
    126125      pls_.join(x0, y[i-1], x0, y[i]);
     
    164163
    165164
    166   void Graph::set_dates(const std::vector<std::string>& date)
     165  void Graph::set_dates(const std::vector<time_t>& date)
    167166  {
    168167    xticks_=date;
     
    186185
    187186
    188   const std::vector<std::string>& Graph::xticks(void)
     187  const std::vector<time_t>& Graph::xticks(void)
    189188  {
    190189    return xticks_;
  • trunk/lib/Graph.h

    r1194 r1197  
    2828#include "Vector.h"
    2929
     30#include <ctime>
    3031#include <string>
    3132#include <vector>
     
    99100       \brief Function setting the dates.
    100101
    101        The date strings must be in svn format since underlying time
    102        conversion are done with the Date class.
    103 
    104        \see Date::svntime(std::string)
     102       The date is given in seconds (since 1/1 1970)
    105103    */
    106     static void set_dates(const std::vector<std::string>& date);
     104    static void set_dates(const std::vector<time_t>& date);
    107105
    108106    /**
     
    112110    void timeformat(const std::string& format);
    113111
    114     static const std::vector<std::string>& xticks(void);
     112    static const std::vector<time_t>& xticks(void);
    115113
    116114    /**
     
    147145    std::string timeformat_;
    148146    std::string title_;
    149     static std::vector<std::string> xticks_;
     147    static std::vector<time_t> xticks_;
    150148    PLFLT xmin_, xmax_, xrange_, ymin_, ymax_, yrange_;
    151149  };
Note: See TracChangeset for help on using the changeset viewer.