Changeset 611
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Stats.cc
r589 r611 100 100 add_author(user); 101 101 102 // FIXME: Peter, remove repeat 103 std::vector<unsigned int>& code = code_stats()[user]; 104 if (code.size() < rev+1){ 105 code.reserve(rev+1); 106 code.resize(rev); 107 if (lt == LineTypeParser::code) 108 code.push_back(n); 102 add(code_stats()[user], rev, lt==LineTypeParser::code, n); 103 add(comment_stats()[user], rev, lt==LineTypeParser::comment, n); 104 add(other_stats()[user], rev, lt==LineTypeParser::other, n); 105 add(copyright_stats()[user], rev, lt==LineTypeParser::copyright, n); 106 } 107 108 109 void Stats::add(std::vector<unsigned int>& vec, unsigned int rev, bool x, 110 unsigned int n) 111 { 112 if (vec.size() < rev+1){ 113 vec.reserve(rev+1); 114 vec.resize(rev); 115 if (x) 116 vec.push_back(n); 109 117 else 110 code.push_back(0);118 vec.push_back(0); 111 119 } 112 else if (lt == LineTypeParser::code) 113 code[rev]+=n; 114 115 std::vector<unsigned int>& comments = comment_stats()[user]; 116 if (comments.size() < rev+1){ 117 comments.reserve(revision() + 1); 118 comments.insert(comments.end(), rev - comments.size(), 0); 119 if (lt == LineTypeParser::comment) 120 comments.push_back(n); 121 else 122 comments.push_back(0); 123 } 124 else if (lt == LineTypeParser::comment) 125 comments[rev]+=n; 126 127 std::vector<unsigned int>& other = other_stats()[user]; 128 if (other.size() < rev+1){ 129 other.reserve(revision() + 1); 130 other.insert(other.end(), rev - other.size(), 0); 131 if (lt == LineTypeParser::other) 132 other.push_back(n); 133 else 134 other.push_back(0); 135 } 136 else if (lt == LineTypeParser::other) 137 other[rev]+=n; 138 139 std::vector<unsigned int>& copy = copyright_stats()[user]; 140 if (copy.size() < rev+1){ 141 copy.reserve(revision() + 1); 142 copy.insert(copy.end(), rev - copy.size(), 0); 143 if (lt == LineTypeParser::copyright) 144 copy.push_back(n); 145 else 146 copy.push_back(0); 147 } 148 else if (lt == LineTypeParser::copyright) 149 copy[rev]+=n; 150 } 120 else if (x) 121 vec[rev]+=n; 122 } 151 123 152 124 -
trunk/lib/Stats.h
r589 r611 200 200 private: 201 201 void accumulate(std::vector<unsigned int>& vec) const; 202 void add(std::vector<unsigned int>& vec, unsigned int rev, bool x, 203 unsigned int n); 204 202 205 virtual void do_parse(const std::string&)=0; 203 206
Note: See TracChangeset
for help on using the changeset viewer.