mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Optimisation: away creation of FontTable for each FontList::fontIterator() call.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25664 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
5013a5cef9
commit
bef58b3b16
@ -28,34 +28,28 @@ using namespace std;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
namespace {
|
||||
|
||||
class matchFT
|
||||
{
|
||||
public:
|
||||
/// used by lower_bound and upper_bound
|
||||
int operator()(FontTable const & a, FontTable const & b) const {
|
||||
return a.pos() < b.pos();
|
||||
}
|
||||
};
|
||||
|
||||
} // anon namespace
|
||||
|
||||
FontList::iterator FontList::fontIterator(pos_type pos)
|
||||
{
|
||||
static Font dummy;
|
||||
FontTable search_elem(pos, dummy);
|
||||
return lower_bound(list_.begin(), list_.end(), search_elem,
|
||||
matchFT());
|
||||
FontList::iterator it = list_.begin();
|
||||
FontList::iterator end = list_.end();
|
||||
for (; it != end; ++it) {
|
||||
if (it->pos() >= pos)
|
||||
break;
|
||||
}
|
||||
return it;
|
||||
}
|
||||
|
||||
|
||||
FontList::const_iterator FontList::fontIterator(pos_type pos) const
|
||||
{
|
||||
static Font dummy;
|
||||
FontTable search_elem(pos, dummy);
|
||||
return lower_bound(list_.begin(), list_.end(), search_elem,
|
||||
matchFT());
|
||||
FontList::const_iterator it = list_.begin();
|
||||
FontList::const_iterator end = list_.end();
|
||||
for (; it != end; ++it) {
|
||||
if (it->pos() >= pos)
|
||||
break;
|
||||
}
|
||||
return it;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user