@@ -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
155168std::optional<Rect> dbWire::getBBox ()
0 commit comments