Skip to content

Commit 8c2b06f

Browse files
committed
deflookup: use more descriptive identifiers
No change in behavior intended with this commit. Related: #98
1 parent b27b9b0 commit 8c2b06f

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

src/lib/deflookup.cc

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ typedef std::map<std::string, TDefByEvt> TDefByFile;
3131
typedef std::map<std::string, TDefByFile> TDefByChecker;
3232

3333
struct DefLookup::Private {
34-
TDefByChecker stor;
34+
TDefByChecker byChecker;
3535
bool usePartialResults;
3636
};
3737

@@ -63,61 +63,65 @@ DefLookup::~DefLookup()
6363

6464
void DefLookup::hashDefect(const Defect &def)
6565
{
66-
TDefByFile &row = d->stor[def.checker];
66+
// categorize by checker
67+
TDefByFile &byPath = d->byChecker[def.checker];
6768

69+
// categorize by path
6870
const DefEvent &evt = def.events[def.keyEventIdx];
6971
const MsgFilter &filter = MsgFilter::inst();
70-
TDefByEvt &col = row[filter.filterPath(evt.fileName)];
71-
TDefByMsg &zCol = col[evt.event];
72-
TDefList &cell = zCol[filter.filterMsg(evt.msg, def.checker)];
72+
TDefByEvt &byEvt = byPath[filter.filterPath(evt.fileName)];
7373

74-
cell.push_back(def);
74+
// categorize by key event and msg
75+
TDefByMsg &byMsg = byEvt[evt.event];
76+
TDefList &defList = byMsg[filter.filterMsg(evt.msg, def.checker)];
77+
78+
defList.push_back(def);
7579
}
7680

7781
bool DefLookup::lookup(const Defect &def)
7882
{
7983
// look for defect class
80-
TDefByChecker::iterator iRow = d->stor.find(def.checker);
81-
if (d->stor.end() == iRow)
84+
TDefByChecker::iterator itByChecker = d->byChecker.find(def.checker);
85+
if (d->byChecker.end() == itByChecker)
8286
return false;
8387

8488
// simplify path
8589
const MsgFilter &filter = MsgFilter::inst();
8690
const DefEvent &evt = def.events[def.keyEventIdx];
87-
const std::string path(filter.filterPath(evt.fileName));
91+
const std::string path = filter.filterPath(evt.fileName);
8892

8993
// look for file name
90-
TDefByFile &row = iRow->second;
91-
TDefByFile::iterator iCol = row.find(path);
92-
if (row.end() == iCol)
94+
TDefByFile &byPath = itByChecker->second;
95+
TDefByFile::iterator itByPath = byPath.find(path);
96+
if (byPath.end() == itByPath)
9397
return false;
9498

95-
TDefByEvt &col = iCol->second;
96-
if (!d->usePartialResults && col.end() != col.find("internal warning"))
99+
TDefByEvt &byEvt = itByPath->second;
100+
if (!d->usePartialResults && byEvt.end() != byEvt.find("internal warning"))
97101
// if the analyzer produced an "internal warning" diagnostic message,
98102
// we assume partial results, which cannot be reliably used for
99103
// differential scan ==> pretend we found what we had been looking
100104
// for, but do not remove anything from the store
101105
return true;
102106

103107
// look by key event
104-
TDefByEvt::iterator iZCol = col.find(evt.event);
105-
if (col.end() == iZCol)
108+
TDefByEvt::iterator itByEvent = byEvt.find(evt.event);
109+
if (byEvt.end() == itByEvent)
106110
return false;
107111

108112
// look by msg
109-
TDefByMsg &zCol = iZCol->second;
110-
TDefByMsg::iterator iCell = zCol.find(
111-
filter.filterMsg(evt.msg, def.checker));
112-
if (zCol.end() == iCell)
113+
TDefByMsg &byMsg = itByEvent->second;
114+
const std::string msg = filter.filterMsg(evt.msg, def.checker);
115+
TDefByMsg::iterator itByMsg = byMsg.find(msg);
116+
if (byMsg.end() == itByMsg)
113117
return false;
114118

115119
// FIXME: nasty over-approximation
116-
TDefList &defs = iCell->second;
117-
unsigned cnt = defs.size();
120+
TDefList &defList = itByMsg->second;
121+
unsigned cnt = defList.size();
118122
if (cnt)
119123
// just remove an arbitrary one
120-
defs.resize(cnt - 1);
124+
defList.resize(cnt - 1);
121125
else
122126
return false;
123127

0 commit comments

Comments
 (0)