- // 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;
- std::time_t lastw = f.lastModified();
- if (lastw != bibfileStatus[f]) {
- changed = true;
- bibfileStatus[f] = lastw;
- }
- }
-
- // 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];
- }
-