git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32912 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2010-01-09 16:15:46 +00:00
parent 62d11f1f3b
commit a397cc81c2

View File

@ -224,7 +224,7 @@ public:
/// A cache for the bibfiles (including bibfiles of loaded child /// A cache for the bibfiles (including bibfiles of loaded child
/// documents), needed for appropriate update of natbib labels. /// documents), needed for appropriate update of natbib labels.
mutable support::FileNameList bibfilesCache_; mutable support::FileNameList bibfiles_cache_;
// FIXME The caching mechanism could be improved. At present, we have a // FIXME The caching mechanism could be improved. At present, we have a
// cache for each Buffer, that caches all the bibliography info for that // cache for each Buffer, that caches all the bibliography info for that
@ -233,9 +233,9 @@ public:
/// A cache for bibliography info /// A cache for bibliography info
mutable BiblioInfo bibinfo_; mutable BiblioInfo bibinfo_;
/// whether the bibinfo cache is valid /// whether the bibinfo cache is valid
bool bibinfoCacheValid_; bool bibinfo_cache_valid_;
/// Cache of timestamps of .bib files /// Cache of timestamps of .bib files
map<FileName, time_t> bibfileStatus_; map<FileName, time_t> bibfile_status_;
mutable RefCache ref_cache_; mutable RefCache ref_cache_;
@ -294,7 +294,7 @@ Buffer::Impl::Impl(Buffer & parent, FileName const & file, bool readonly_,
: lyx_clean(true), bak_clean(true), unnamed(false), : lyx_clean(true), bak_clean(true), unnamed(false),
read_only(readonly_), filename(file), file_fully_loaded(false), read_only(readonly_), filename(file), file_fully_loaded(false),
toc_backend(&parent), macro_lock(false), timestamp_(0), toc_backend(&parent), macro_lock(false), timestamp_(0),
checksum_(0), wa_(0), undo_(parent), bibinfoCacheValid_(false), checksum_(0), wa_(0), undo_(parent), bibinfo_cache_valid_(false),
cloned_buffer_(cloned_buffer), parent_buffer(0) cloned_buffer_(cloned_buffer), parent_buffer(0)
{ {
if (!cloned_buffer_) { if (!cloned_buffer_) {
@ -1605,13 +1605,13 @@ void Buffer::updateBibfilesCache(UpdateScope scope) const
return; return;
} }
d->bibfilesCache_.clear(); d->bibfiles_cache_.clear();
for (InsetIterator it = inset_iterator_begin(inset()); it; ++it) { for (InsetIterator it = inset_iterator_begin(inset()); it; ++it) {
if (it->lyxCode() == BIBTEX_CODE) { if (it->lyxCode() == BIBTEX_CODE) {
InsetBibtex const & inset = InsetBibtex const & inset =
static_cast<InsetBibtex const &>(*it); static_cast<InsetBibtex const &>(*it);
support::FileNameList const bibfiles = inset.getBibFiles(); support::FileNameList const bibfiles = inset.getBibFiles();
d->bibfilesCache_.insert(d->bibfilesCache_.end(), d->bibfiles_cache_.insert(d->bibfiles_cache_.end(),
bibfiles.begin(), bibfiles.begin(),
bibfiles.end()); bibfiles.end());
} else if (it->lyxCode() == INCLUDE_CODE) { } else if (it->lyxCode() == INCLUDE_CODE) {
@ -1620,19 +1620,19 @@ void Buffer::updateBibfilesCache(UpdateScope scope) const
inset.updateBibfilesCache(); inset.updateBibfilesCache();
support::FileNameList const & bibfiles = support::FileNameList const & bibfiles =
inset.getBibfilesCache(); inset.getBibfilesCache();
d->bibfilesCache_.insert(d->bibfilesCache_.end(), d->bibfiles_cache_.insert(d->bibfiles_cache_.end(),
bibfiles.begin(), bibfiles.begin(),
bibfiles.end()); bibfiles.end());
} }
} }
// the bibinfo cache is now invalid // the bibinfo cache is now invalid
d->bibinfoCacheValid_ = false; d->bibinfo_cache_valid_ = false;
} }
void Buffer::invalidateBibinfoCache() void Buffer::invalidateBibinfoCache()
{ {
d->bibinfoCacheValid_ = false; d->bibinfo_cache_valid_ = false;
} }
@ -1644,10 +1644,10 @@ support::FileNameList const & Buffer::getBibfilesCache(UpdateScope scope) const
return pbuf->getBibfilesCache(); return pbuf->getBibfilesCache();
// We update the cache when first used instead of at loading time. // We update the cache when first used instead of at loading time.
if (d->bibfilesCache_.empty()) if (d->bibfiles_cache_.empty())
const_cast<Buffer *>(this)->updateBibfilesCache(scope); const_cast<Buffer *>(this)->updateBibfilesCache(scope);
return d->bibfilesCache_; return d->bibfiles_cache_;
} }
@ -1678,18 +1678,18 @@ void Buffer::checkBibInfoCache() const
support::FileNameList::const_iterator en = bibfilesCache.end(); support::FileNameList::const_iterator en = bibfilesCache.end();
for (; ei != en; ++ ei) { for (; ei != en; ++ ei) {
time_t lastw = ei->lastModified(); time_t lastw = ei->lastModified();
time_t prevw = d->bibfileStatus_[*ei]; time_t prevw = d->bibfile_status_[*ei];
if (lastw != prevw) { if (lastw != prevw) {
d->bibinfoCacheValid_ = false; d->bibinfo_cache_valid_ = false;
d->bibfileStatus_[*ei] = lastw; d->bibfile_status_[*ei] = lastw;
} }
} }
if (!d->bibinfoCacheValid_) { if (!d->bibinfo_cache_valid_) {
d->bibinfo_.clear(); d->bibinfo_.clear();
for (InsetIterator it = inset_iterator_begin(inset()); it; ++it) for (InsetIterator it = inset_iterator_begin(inset()); it; ++it)
it->fillWithBibKeys(d->bibinfo_, it); it->fillWithBibKeys(d->bibinfo_, it);
d->bibinfoCacheValid_ = true; d->bibinfo_cache_valid_ = true;
} }
} }