]> git.lyx.org Git - features.git/commitdiff
Optimisation: away creation of FontTable for each FontList::fontIterator() call.
authorAbdelrazak Younes <younes@lyx.org>
Wed, 16 Jul 2008 12:09:54 +0000 (12:09 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Wed, 16 Jul 2008 12:09:54 +0000 (12:09 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25664 a592a061-630c-0410-9148-cb99ea01b6c8

src/FontList.cpp

index f6b456d9db495d4383cede00d8e38a71dbd77151..954ab4a1d5836a8fee8514428eaa63c6f6bbfc56 100644 (file)
@@ -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;
 }