Skip to content

Commit 7eda728

Browse files
authored
Merge pull request #9678 from AcKoucher/odb-renaming-vars
odb: improve naming for future bug fix review
2 parents 9374207 + 23a6f88 commit 7eda728

2 files changed

Lines changed: 31 additions & 18 deletions

File tree

src/odb/include/odb/db.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3663,9 +3663,9 @@ class dbWire : public dbObject
36633663
void append(dbWire* wire, bool singleSegmentWire = false);
36643664

36653665
///
3666-
/// Get junction id associated with the term
3666+
/// Get junction id associated with the terminal.
36673667
///
3668-
uint32_t getTermJid(int termid) const;
3668+
uint32_t getTermJid(int term_id) const;
36693669

36703670
///
36713671
/// Get the shape of this shape-id.

src/odb/src/db/dbWire.cpp

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,32 +124,45 @@ void dbWire::addOneSeg(unsigned char op, int value)
124124
wire->opcodes_.push_back(op);
125125
}
126126

127-
uint32_t dbWire::getTermJid(const int termid) const
127+
uint32_t dbWire::getTermJid(const int term_id) const
128128
{
129129
_dbWire* wire = (_dbWire*) this;
130-
int topcd = kIterm;
131-
int ttid = termid;
132-
if (termid < 0) {
133-
topcd = kBterm;
134-
ttid = -termid;
130+
int target_op_code = kIterm;
131+
int target_term_id = term_id;
132+
133+
if (term_id < 0) {
134+
target_op_code = kBterm;
135+
target_term_id = -term_id;
135136
}
136-
const uint32_t wlen = wire->length();
137-
uint32_t jj;
138-
for (jj = 0; jj < wlen; jj++) {
139-
if ((wire->opcodes_[jj] & WOP_OPCODE_MASK) == topcd) {
140-
if (wire->data_[jj] == ttid) {
137+
138+
const uint32_t number_of_junctions = wire->length();
139+
140+
uint32_t junction_id;
141+
for (junction_id = 0; junction_id < number_of_junctions; junction_id++) {
142+
const WireOp junction_op_code
143+
= static_cast<WireOp>(wire->opcodes_[junction_id] & WOP_OPCODE_MASK);
144+
145+
if (junction_op_code == target_op_code) {
146+
if (wire->data_[junction_id] == target_term_id) {
141147
break;
142148
}
143149
}
144150
}
145-
if (jj == wlen) {
151+
152+
if (junction_id == number_of_junctions) {
146153
return 0;
147154
}
148-
jj--;
149-
if ((wire->opcodes_[jj] & WOP_OPCODE_MASK) == kProperty) {
150-
jj--;
155+
156+
junction_id--;
157+
158+
const WireOp junction_op_code
159+
= static_cast<WireOp>(wire->opcodes_[junction_id] & WOP_OPCODE_MASK);
160+
161+
if (junction_op_code == kProperty) {
162+
junction_id--;
151163
}
152-
return jj;
164+
165+
return junction_id;
153166
}
154167

155168
std::optional<Rect> dbWire::getBBox()

0 commit comments

Comments
 (0)