]> git.lyx.org Git - lyx.git/blobdiff - src/BufferList.cpp
Routines to retrieve HTML style information.
[lyx.git] / src / BufferList.cpp
index 4f7c4e0ac4a2f34001420b28c19409b66dcb1180..4f6c848452c7605a09065ade1548493f47842af1 100644 (file)
@@ -3,7 +3,7 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author Lars Gullik Bjønnes
+ * \author Lars Gullik Bjønnes
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -294,17 +294,31 @@ bool BufferList::exists(FileName const & fname) const
 
 bool BufferList::isLoaded(Buffer const * b) const
 {
-       LASSERT(b, /**/);
        BufferStorage::const_iterator cit =
                find(bstore.begin(), bstore.end(), b);
        return cit != bstore.end();
 }
 
 
+namespace {
+struct equivalent_to : public binary_function<FileName, FileName, bool>
+{
+       bool operator()(FileName const & x, FileName const & y) const
+       { return equivalent(x, y); }
+};
+}
+
+
 Buffer * BufferList::getBuffer(support::FileName const & fname) const
 {
+       // 1) cheap test, using string comparison of file names
        BufferStorage::const_iterator it = find_if(bstore.begin(), bstore.end(),
                bind(equal_to<FileName>(), bind(&Buffer::fileName, _1), fname));
+       if (it != bstore.end())
+                       return *it;
+       // 2) possibly expensive test, using quivalence test of file names
+       it = find_if(bstore.begin(), bstore.end(),
+               bind(equivalent_to(), bind(&Buffer::fileName, _1), fname));
        return it != bstore.end() ? (*it) : 0;
 }