SnapshotPtr UniformSample::getSnapshot() const { boost::lock_guard<boost::mutex> lock(mutex_); Int64Vector::const_iterator begin_itr(values_.begin()); Int64Vector::const_iterator end_itr(values_.begin()); std::advance(end_itr, size()); return SnapshotPtr(new Snapshot(ValueVector(begin_itr, end_itr))); }
cov::status_t cov_range_scope_t::calc_stats(cov_stats_t *stats) { /* * Check inputs */ if (start_ > end_) return cov::SUPPRESSED; /* invalid range */ if (start_ == 0 || end_ == 0) return cov::SUPPRESSED; /* invalid range */ unsigned int lastline = file_->num_lines(); if (start_ > lastline) return cov::SUPPRESSED; /* range is outside file */ if (end_ > lastline) end_ = lastline; /* clamp range to file */ /* we treat this as a set */ hashtable_t<void, void> *blocks_seen = new hashtable_t<void, void>; /* we treat this as a set */ hashtable_t<void, void> *functions_seen = new hashtable_t<void, void>; cov_stats_t block_stats; cov_stats_t function_stats; cov_stats_t line_stats; cov_file_t::line_iterator_t start_itr(file_, start_); cov_file_t::line_iterator_t end_itr(file_, end_+1); for (cov_file_t::line_iterator_t itr = start_itr ; itr != end_itr ; ++itr) { cov_line_t *line = itr.line(); line_stats.add_line(line->status()); for (list_iterator_t<cov_block_t> bitr = line->blocks().first() ; *bitr ; ++bitr) { cov_block_t *b = *bitr; if (!blocks_seen->lookup(b)) { b->calc_stats(&block_stats); blocks_seen->insert(b, b); cov_function_t *f = b->function(); if (!functions_seen->lookup(f)) { f->calc_stats(&function_stats); functions_seen->insert(f, f); } } } } stats->accumulate_blocks(&block_stats); stats->accumulate_lines(&line_stats); stats->accumulate_functions(&function_stats); stats->accumulate_calls(&block_stats); stats->accumulate_branches(&block_stats); delete blocks_seen; delete functions_seen; return stats->status_by_lines(); }