Andre Poenitz <[EMAIL PROTECTED]> writes:
| > | map<string, vector<TocItem> >::iterator it = l.find(type);
| > | if (it == l.end()) {
| > | vector<TocItem> vti;
| > | vti.push_back(ti);
| > | l[type] = vti;
| > | } else {
| > | it->second.push_back(ti);
| > | }
| > |
| > | Can't the above code be replaced by simply
| > | l[type].push_back(ti);
|
| > I think that the construct used in buffer.C now is quite nice, don't
| > simplify _too_ much.
|
| I find Dekel's suggestion very sensible. The eight-line solution is not
| only longer in code but slower in some cases (extra creation/copy/deletion
| of the vector).
eh? did you look at buffer.C?
SingleList & item = l[type];
TocItem tmp;
tmp.par = par;
tmp.depth = 0;
tmp.str = tostr(item.size()+1) + ". " + par->String(this, false);
item.push_back(tmp);
This is used now. and since we need the item.size() the
l[type].push_back(..) variant will not do. And I guess Delkel realized
that when he wrote the above.
Lgb