- BufferStorage::iterator it =
- find_if(bstore.begin(), bstore.end(),
- bind(equal_to<string>(),
- bind(&Buffer::absFileName, _1),
- s));
+ // 1) cheap test, using string comparison of file names
+ BufferStorage::const_iterator it = find_if(bstore.begin(), bstore.end(),
+ lyx::bind(equal_to<FileName>(), lyx::bind(&Buffer::fileName, _1), fname));
+ if (it != bstore.end())
+ return *it;
+ // 2) possibly expensive test, using equivalence test of file names
+ it = find_if(bstore.begin(), bstore.end(),
+ lyx::bind(equivalent_to(), lyx::bind(&Buffer::fileName, _1), fname));
+ if (it != bstore.end())
+ return *it;
+
+ if (internal) {
+ // 1) cheap test, using string comparison of file names
+ BufferStorage::const_iterator it = find_if(binternal.begin(), binternal.end(),
+ lyx::bind(equal_to<FileName>(), lyx::bind(&Buffer::fileName, _1), fname));
+ if (it != binternal.end())
+ return *it;
+ // 2) possibly expensive test, using equivalence test of file names
+ it = find_if(binternal.begin(), binternal.end(),
+ lyx::bind(equivalent_to(), lyx::bind(&Buffer::fileName, _1), fname));
+ if (it != binternal.end())
+ return *it;
+ }