Michael Gerz wrote:
Abdel,
be careful with these micro-optimization. Eventually, you will shoot
yourself in the foot!
Don't worry, I am proceeding with caution.
Are you sure that these optimization are really that beneficial?
Yes.
@@ -277,29 +277,32 @@
docstring Counters::labelItem(docstring const & ctr,
docstring const & numbertype)
{
- if (counterList.find(ctr) == counterList.end()) {
+ CounterList::const_iterator const cit = counterList.find(ctr);
+ if (cit == counterList.end()) {
lyxerr << "Counter "
<< to_utf8(ctr)
<< " does not exist." << endl;
return docstring();
}
+ int val = cit->second.value();
+
if (numbertype == "hebrew")
- return docstring(1, hebrewCounter(value(ctr)));
+ return docstring(1, hebrewCounter(val));
I fail to see why
value(ctr)
is the same as
val = cit->second.value()
Yes, that is because Counters::value() is doing the same map search for
nothing:
int Counters::value(docstring const & ctr) const
{
CounterList::const_iterator const cit = counterList.find(ctr);
if (cit == counterList.end()) {
lyxerr << "value: Counter does not exist: "
<< to_utf8(ctr) << endl;
return 0;
}
return cit->second.value();
}
Abdel.