Abdelrazak Younes wrote:

> I am OK with it but maybe the real problem is why getInset is so slow?
> Looking at InsetList::insetIterator(pos_type pos), this is no wonder
> really:
> 
> InsetList::iterator InsetList::insetIterator(pos_type pos)
> {
> InsetTable search_elem(pos, 0);
> return lower_bound(list_.begin(), list_.end(), search_elem,
> InsetTablePosLess());
> }
> 
> InsetTable is basically 'pair<pos, Inset*>', so this InsetList is
> basically reimplementing std::map in a less efficient way. Just

Are you sure it's less efficient? AFAICS this is O(ln n) just like std::map,
constants may vary (in one side or the other). 

> replacing the 'vector<InsetTable>' with a 'map<pos, Inset*>' will clean
> halves the code. And then you could just use the standard map iterator
> anywhere it makes sense; and I bet there is a lot of case were it make
> sense:

The code will be a bit cleaner maybe... but it is self-contained and clean
enough, and has been working flawlessly for ages... so be sure there is
really a gain if you are going to switch.

A/


Reply via email to