Commit f08d0452 authored by Igor Kushnir's avatar Igor Kushnir
Browse files

Optimize and deduplicate code in ParamIterator()

Don't create and assign to d->m_prefix two QString objects if the paren
is not closed. m_prefix is used only in ParamIterator::prefix(), which
in turn is not used by ParamIterator itself, so the code reordering does
not change behavior.
parent 5d3cdf9f
......@@ -335,19 +335,16 @@ ParamIterator::ParamIterator(const QString& parens, const QString& source, int o
} else {
if (parenBegin != -1) {
//We have a valid prefix before an opening-paren. Take the prefix, and start iterating parameters.
d->m_prefix = d->m_source.mid(offset, parenBegin - offset);
d->m_cur = parenBegin + 1;
d->m_curEnd = d->next();
if (d->m_curEnd == d->m_source.length()) {
//The paren was not closed. It might be an identifier like "operator<", so count everything as prefix.
d->m_prefix = d->m_source.mid(offset);
d->m_curEnd = d->m_end = d->m_cur = d->m_source.length();
}
} else {
//We have neither found an ending-character, nor an opening-paren, so take the whole input and end
d->m_prefix = d->m_source.mid(offset);
d->m_curEnd = d->m_end = d->m_cur = d->m_source.length();
}
if (d->m_curEnd != d->m_source.length()) {
d->m_prefix = d->m_source.mid(offset, parenBegin - offset);
return;
} // else: the paren was not closed. It might be an identifier like "operator<", so count everything as prefix.
} // else: we have neither found an ending-character, nor an opening-paren, so take the whole input and end.
d->m_prefix = d->m_source.mid(offset);
d->m_curEnd = d->m_end = d->m_cur = d->m_source.length();
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment