Changeset 527 for trunk/lib/Stats.cc


Ignore:
Timestamp:
Dec 25, 2007, 6:11:09 AM (14 years ago)
Author:
Peter Johansson
Message:

removing valid variable - starting to refactor Stats class.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Stats.cc

    r519 r527  
    5151
    5252  Stats::Stats(const std::string& path)
    53     : valid_(true)
    5453  {
    5554    // Make sure latest revision is set properly
     
    115114    last_changed_rev_ = std::max(last_changed_rev_, rhs.last_changed_rev_);
    116115    add_authors(rhs.authors().begin(), rhs.authors().end());
    117     valid_ &= rhs.valid();
    118     // if cache not valid no need to update it
    119     if (valid()) {
    120       base_add(rhs.code_.begin(), rhs.code_.end(), code_);
    121       base_add(rhs.comments_.begin(), rhs.comments_.end(), comments_);
    122       base_add(rhs.other_.begin(), rhs.other_.end(), other_);
    123       base_add(rhs.total_.begin(), rhs.total_.end(), total_);
    124     }
     116    base_add(rhs.code_.begin(), rhs.code_.end(), code_);
     117    base_add(rhs.comments_.begin(), rhs.comments_.end(), comments_);
     118    base_add(rhs.other_.begin(), rhs.other_.end(), other_);
     119    base_add(rhs.total_.begin(), rhs.total_.end(), total_);
    125120  }
    126121
     
    147142                                              std::string user) const
    148143  {
    149     // Peter, we should avoid calling this function prior all
    150     // statistics are calculated. If, for some reason, this is not
    151     // possible call update_stats() first, however, that function is
    152     // not const so some redesign is needed (e.g. making cache mutable
    153     // or making them pointers)
    154     assert(valid() && "trying to access invalid cache of statistics");
    155144    v_map::const_iterator iter(m.find(std::string(user)));
    156145    if (iter==m.end())
     
    189178  u_int Stats::lines(const std::string& user) const
    190179  {
    191     assert(valid()); return get_vector(total_, "all").back();
     180    return get_vector(total_, "all").back();
    192181  }
    193182
     
    195184  void Stats::parse(const std::string& path)
    196185  {
    197     valid_=false;
    198186    // First we let inherited class do parsing
    199187    do_parse(path);
     
    225213  void Stats::plot_summary(const std::string& filename) const
    226214  {
    227     assert(valid());
    228215    plot_init(filename);
    229216    GnuplotFE* gp=GnuplotFE::instance();
     
    308295    VectorPlus<u_int> vp;
    309296    total_["all"] = vp(vp(code_["all"], comments_["all"]), other_["all"]);
    310     valid_=true;
    311297  }
    312298
Note: See TracChangeset for help on using the changeset viewer.