Commit f9c203bb authored by zhanxw's avatar zhanxw

simplify codes

parent 4c25353d
......@@ -856,10 +856,7 @@ FileType AbstractFileReader::checkFileType(const char* fileName) {
*/
int removeEmptyField(std::vector<std::string>* fields) {
int s = fields->size();
fields->erase(
std::remove_if(fields->begin(), fields->end(),
[](const std::string& a) { return a.size() == 0; }),
fields->end());
fields->erase(std::remove(fields->begin(), fields->end(), ""), fields->end());
s -= fields->size();
return s;
};
......
......@@ -31,6 +31,10 @@ struct FlatMetric {
double totalElapsed;
};
bool compareFlatMetric(const FlatMetric& a, const FlatMetric& b) {
return a.avgElapsed > b.avgElapsed;
}
void Profiler::dump() {
std::vector<FlatMetric> v;
for (std::unordered_map<std::string, Metric>::iterator it = data.begin();
......@@ -38,10 +42,7 @@ void Profiler::dump() {
v.push_back(
FlatMetric(it->first, it->second.nHits, it->second.timer.getSeconds()));
}
std::sort(v.begin(), v.end(),
[](const FlatMetric& a, const FlatMetric& b) -> bool {
return a.avgElapsed > b.avgElapsed;
});
std::sort(v.begin(), v.end(), compareFlatMetric);
for (size_t i = 0; i != v.size(); ++i) {
const FlatMetric& x = v[i];
fprintf(stderr,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment