- // Cache the labels
- typedef std::map<Buffer const *, BiblioInfo> CachedMap;
- static CachedMap cached_keys;
-
- // and cache the timestamp of the bibliography files.
- static std::map<FileName, time_t> bibfileStatus;
-
- BiblioInfo biblist;
-
- vector<FileName> const & bibfilesCache = buffer.getBibfilesCache();
- // compare the cached timestamps with the actual ones.
- bool changed = false;
- for (vector<FileName>::const_iterator it = bibfilesCache.begin();
- it != bibfilesCache.end(); ++ it) {
- FileName const f = *it;
- try {
- std::time_t lastw = fs::last_write_time(f.toFilesystemEncoding());
- if (lastw != bibfileStatus[f]) {
- changed = true;
- bibfileStatus[f] = lastw;
- }
- }
- catch (fs::filesystem_error & fserr) {
- changed = true;
- lyxerr << "Couldn't find or read bibtex file "
- << f << endl;
- LYXERR(Debug::DEBUG) << "Fs error: "
- << fserr.what() << endl;
- }
- }
-
- // build the list only if the bibfiles have been changed
- if (cached_keys[&buffer].empty() || bibfileStatus.empty() || changed) {
- biblist.fillWithBibKeys(&buffer);
- cached_keys[&buffer] = biblist;
- } else
- // use the cached keys
- biblist = cached_keys[&buffer];
-