Internals: Favor const_iterator (in a few obvious spots, more needed). No functional change.

This commit is contained in:
Wilson Snyder 2020-03-15 18:34:09 -04:00
parent 57068b95ef
commit 5d9d1cc09f
12 changed files with 29 additions and 31 deletions

View File

@ -173,12 +173,12 @@ void VlThreadPool::profileDump(const char* filenamep, vluint64_t ticksElapsed) {
VlMTaskVertex::yields());
vluint32_t thread_id = 0;
for (ProfileSet::iterator pit = m_allProfiles.begin();
for (ProfileSet::const_iterator pit = m_allProfiles.begin();
pit != m_allProfiles.end(); ++pit) {
++thread_id;
bool printing = false; // False while in warmup phase
for (ProfileTrace::iterator eit = (*pit)->begin();
for (ProfileTrace::const_iterator eit = (*pit)->begin();
eit != (*pit)->end(); ++eit) {
switch (eit->m_type) {
case VlProfileRec::TYPE_BARRIER:

View File

@ -350,7 +350,7 @@ void V3Graph::dumpDotFile(const string& filename, bool colorAsSubgraph) const {
// Print vertices
int n = 0;
string subgr;
for (SubgraphMmap::iterator it = subgraphs.begin(); it!=subgraphs.end(); ++it) {
for (SubgraphMmap::const_iterator it = subgraphs.begin(); it != subgraphs.end(); ++it) {
string vertexSubgraph = it->first;
V3GraphVertex* vertexp = it->second;
numMap[vertexp] = n;

View File

@ -46,7 +46,7 @@ class V3LanguageWords {
static const_iterator begin() { return s().s_kwdMap.begin(); }
static const_iterator end() { return s().s_kwdMap.end(); }
static string isKeyword(const string& kwd) {
KeywordMap::iterator it = s().s_kwdMap.find(kwd);
KeywordMap::const_iterator it = s().s_kwdMap.find(kwd);
if (it == s().s_kwdMap.end()) return "";
return it->second;
}

View File

@ -55,11 +55,9 @@ void V3LinkLevel::modSortByLevel() {
ModVec mods; // Modules
ModVec tops; // Top level modules
for (AstNodeModule* nodep = v3Global.rootp()->modulesp();
nodep; nodep=VN_CAST(nodep->nextp(), NodeModule)) {
if (nodep->level()<=2) {
tops.push_back(nodep);
}
for (AstNodeModule* nodep = v3Global.rootp()->modulesp(); nodep;
nodep = VN_CAST(nodep->nextp(), NodeModule)) {
if (nodep->level() <= 2) tops.push_back(nodep);
mods.push_back(nodep);
}
if (tops.size() >= 2) {
@ -69,7 +67,7 @@ void V3LinkLevel::modSortByLevel() {
<<secp->warnMore()
<<"... Suggest see manual; fix the duplicates, or use --top-module to select top."
<<V3Error::warnContextNone());
for (ModVec::iterator it = tops.begin(); it != tops.end(); ++it) {
for (ModVec::const_iterator it = tops.begin(); it != tops.end(); ++it) {
AstNode* alsop = *it;
std::cout<<secp->warnMore()<<"... Top module "<<alsop->prettyNameQ()<<endl
<<alsop->warnContextSecondary();

View File

@ -247,7 +247,7 @@ void V3Options::addArg(const string& arg) {
string V3Options::allArgsString() {
string out;
for (std::list<string>::iterator it=m_impp->m_allArgs.begin();
for (std::list<string>::const_iterator it = m_impp->m_allArgs.begin();
it != m_impp->m_allArgs.end(); ++it) {
if (out != "") out += " ";
out += *it;

View File

@ -88,10 +88,8 @@ public:
PartPtrIdMap() : m_nextId(0) {}
// METHODS
vluint64_t findId(const void* ptrp) const {
PtrMap::iterator it = m_id.find(ptrp);
if (it != m_id.end()) {
return it->second;
}
PtrMap::const_iterator it = m_id.find(ptrp);
if (it != m_id.end()) return it->second;
m_id[ptrp] = m_nextId;
return m_nextId++;
}

View File

@ -140,12 +140,12 @@ class StatsReport {
// Header
os<<" Stat "<<std::left<<std::setw(maxWidth-5-2)<<"";
for (Stages::iterator it = stages.begin(); it!=stages.end(); ++it) {
for (Stages::const_iterator it = stages.begin(); it != stages.end(); ++it) {
os<<" "<<std::left<<std::setw(9)<<*it;
}
os<<endl;
os<<" -------- "<<std::left<<std::setw(maxWidth-5-2)<<"";
for (Stages::iterator it = stages.begin(); it!=stages.end(); ++it) {
for (Stages::const_iterator it = stages.begin(); it != stages.end(); ++it) {
os<<" "<<std::left<<std::setw(9)<<"-------";
}
//os<<endl;
@ -154,7 +154,7 @@ class StatsReport {
string lastName = "__NONE__";
string lastCommaName = "__NONE__";
unsigned col = 0;
for (ByName::iterator it = byName.begin(); it!=byName.end(); ++it) {
for (ByName::const_iterator it = byName.begin(); it != byName.end(); ++it) {
const V3Statistic* repp = it->second;
if (lastName != repp->name()) {
lastName = repp->name();

View File

@ -689,7 +689,7 @@ void V3TSP::selfTestString() {
expect.push_back("3");
if (VL_UNCOVERABLE(expect != result)) {
for (std::vector<string>::iterator it = result.begin(); it != result.end(); ++it) {
for (std::vector<string>::const_iterator it = result.begin(); it != result.end(); ++it) {
cout<<*it<<" ";
}
cout<<endl;

View File

@ -157,7 +157,7 @@ int main(int argc, char** argv, char** env) {
{
const VlStringSet& readFiles = top.opt.readFiles();
for (VlStringSet::iterator it = readFiles.begin(); it != readFiles.end(); ++it) {
for (VlStringSet::const_iterator it = readFiles.begin(); it != readFiles.end(); ++it) {
string filename = *it;
top.readCoverage(filename);
}
@ -183,7 +183,7 @@ int main(int argc, char** argv, char** env) {
V3Error::abortIfWarnings();
if (top.opt.unlink()) {
const VlStringSet& readFiles = top.opt.readFiles();
for (VlStringSet::iterator it = readFiles.begin(); it != readFiles.end(); ++it) {
for (VlStringSet::const_iterator it = readFiles.begin(); it != readFiles.end(); ++it) {
string filename = *it;
unlink(filename.c_str());
}

View File

@ -123,7 +123,7 @@ public:
void dump() {
UINFO(2,"dumpPoints...\n");
VlcPoint::dumpHeader();
for (VlcPoints::ByName::iterator it=begin(); it!=end(); ++it) {
for (VlcPoints::ByName::const_iterator it = begin(); it != end(); ++it) {
const VlcPoint& point = pointNumber(it->second);
point.dump();
}
@ -133,7 +133,7 @@ public:
}
vluint64_t findAddPoint(const string& name, vluint64_t count) {
vluint64_t pointnum;
NameMap::iterator iter = m_nameMap.find(name);
NameMap::const_iterator iter = m_nameMap.find(name);
if (iter != m_nameMap.end()) {
pointnum = iter->second;
m_points[pointnum].countInc(count);

View File

@ -118,7 +118,7 @@ public:
void dump(bool bucketsToo) {
UINFO(2,"dumpTests...\n");
VlcTest::dumpHeader();
for (VlcTests::ByName::iterator it=begin(); it!=end(); ++it) {
for (VlcTests::ByName::const_iterator it = begin(); it != end(); ++it) {
(*it)->dump(bucketsToo);
}
}

View File

@ -75,7 +75,7 @@ void VlcTop::writeCoverage(const string& filename) {
}
os << "# SystemC::Coverage-3" << endl;
for (VlcPoints::ByName::iterator it=m_points.begin(); it!=m_points.end(); ++it) {
for (VlcPoints::ByName::const_iterator it = m_points.begin(); it != m_points.end(); ++it) {
const VlcPoint& point = m_points.pointNumber(it->second);
os <<"C '"<<point.name()<<"' " << point.count()<<endl;
}
@ -98,7 +98,7 @@ void VlcTop::rank() {
// Sort by computrons, so fast tests get selected first
std::vector<VlcTest*> bytime;
for (VlcTests::ByName::iterator it=m_tests.begin(); it!=m_tests.end(); ++it) {
for (VlcTests::ByName::const_iterator it = m_tests.begin(); it != m_tests.end(); ++it) {
VlcTest* testp = *it;
if (testp->bucketsCovered()) { // else no points, so can't help us
bytime.push_back(*it);
@ -107,7 +107,7 @@ void VlcTop::rank() {
sort(bytime.begin(), bytime.end(), CmpComputrons()); // Sort the vector
VlcBuckets remaining;
for (VlcPoints::ByName::iterator it=m_points.begin(); it!=m_points.end(); ++it) {
for (VlcPoints::ByName::const_iterator it = m_points.begin(); it != m_points.end(); ++it) {
VlcPoint* pointp = &points().pointNumber(it->second);
// If any tests hit this point, then we'll need to cover it.
if (pointp->testsCovering()) { remaining.addData(pointp->pointNum(), 1); }
@ -145,7 +145,7 @@ void VlcTop::rank() {
void VlcTop::annotateCalc() {
// Calculate per-line information into filedata structure
for (VlcPoints::ByName::iterator it=m_points.begin(); it!=m_points.end(); ++it) {
for (VlcPoints::ByName::const_iterator it = m_points.begin(); it != m_points.end(); ++it) {
const VlcPoint& point = m_points.pointNumber(it->second);
string filename = point.filename();
int lineno = point.lineno();
@ -171,9 +171,10 @@ void VlcTop::annotateCalcNeeded() {
//UINFO(1,"Source "<<source.name()<<endl);
if (opt.annotateAll()) source.needed(true);
VlcSource::LinenoMap& lines = source.lines();
for (VlcSource::LinenoMap::iterator lit=lines.begin(); lit!=lines.end(); ++lit) {
for (VlcSource::LinenoMap::iterator lit = lines.begin(); lit != lines.end(); ++lit) {
VlcSource::ColumnMap& cmap = lit->second;
for (VlcSource::ColumnMap::iterator cit=cmap.begin(); cit!=cmap.end(); ++cit) {
for (VlcSource::ColumnMap::iterator cit = cmap.begin(); cit != cmap.end();
++cit) {
VlcSourceCount& col = cit->second;
//UINFO(0,"Source "<<source.name()<<":"<<col.lineno()<<":"<<col.column()<<endl);
++totCases;
@ -227,7 +228,8 @@ void VlcTop::annotateOutputFiles(const string& dirname) {
VlcSource::LinenoMap::iterator lit=lines.find(lineno);
if (lit != lines.end()) {
VlcSource::ColumnMap& cmap = lit->second;
for (VlcSource::ColumnMap::iterator cit=cmap.begin(); cit!=cmap.end(); ++cit) {
for (VlcSource::ColumnMap::iterator cit = cmap.begin(); cit != cmap.end();
++cit) {
VlcSourceCount& col = cit->second;
//UINFO(0,"Source "<<source.name()<<":"<<col.lineno()<<":"<<col.column()<<endl);
os<<(col.ok()?" ":"%")