mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
More work toward speeding up the bibfile caching stuff.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35103 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
4509607bf6
commit
e992140685
@ -256,6 +256,8 @@ public:
|
|||||||
mutable BiblioInfo bibinfo_;
|
mutable BiblioInfo bibinfo_;
|
||||||
/// whether the bibinfo cache is valid
|
/// whether the bibinfo cache is valid
|
||||||
bool bibinfo_cache_valid_;
|
bool bibinfo_cache_valid_;
|
||||||
|
/// whether the bibfile cache is valid
|
||||||
|
bool bibfile_cache_valid_;
|
||||||
/// Cache of timestamps of .bib files
|
/// Cache of timestamps of .bib files
|
||||||
map<FileName, time_t> bibfile_status_;
|
map<FileName, time_t> bibfile_status_;
|
||||||
|
|
||||||
@ -323,7 +325,8 @@ Buffer::Impl::Impl(Buffer * owner, FileName const & file, bool readonly_,
|
|||||||
read_only(readonly_), filename(file), file_fully_loaded(false),
|
read_only(readonly_), filename(file), file_fully_loaded(false),
|
||||||
toc_backend(owner), macro_lock(false), timestamp_(0),
|
toc_backend(owner), macro_lock(false), timestamp_(0),
|
||||||
checksum_(0), wa_(0), gui_(0), undo_(*owner), bibinfo_cache_valid_(false),
|
checksum_(0), wa_(0), gui_(0), undo_(*owner), bibinfo_cache_valid_(false),
|
||||||
cloned_buffer_(cloned_buffer), doing_export(false), parent_buffer(0)
|
bibfile_cache_valid_(false), cloned_buffer_(cloned_buffer),
|
||||||
|
doing_export(false), parent_buffer(0)
|
||||||
{
|
{
|
||||||
if (!cloned_buffer_) {
|
if (!cloned_buffer_) {
|
||||||
temppath = createBufferTmpDir();
|
temppath = createBufferTmpDir();
|
||||||
@ -338,6 +341,7 @@ Buffer::Impl::Impl(Buffer * owner, FileName const & file, bool readonly_,
|
|||||||
bibfiles_cache_ = cloned_buffer_->d->bibfiles_cache_;
|
bibfiles_cache_ = cloned_buffer_->d->bibfiles_cache_;
|
||||||
bibinfo_ = cloned_buffer_->d->bibinfo_;
|
bibinfo_ = cloned_buffer_->d->bibinfo_;
|
||||||
bibinfo_cache_valid_ = cloned_buffer_->d->bibinfo_cache_valid_;
|
bibinfo_cache_valid_ = cloned_buffer_->d->bibinfo_cache_valid_;
|
||||||
|
bibfile_cache_valid_ = cloned_buffer_->d->bibfile_cache_valid_;
|
||||||
bibfile_status_ = cloned_buffer_->d->bibfile_status_;
|
bibfile_status_ = cloned_buffer_->d->bibfile_status_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1716,18 +1720,22 @@ void Buffer::updateBibfilesCache(UpdateScope scope) const
|
|||||||
} else if (it->lyxCode() == INCLUDE_CODE) {
|
} else if (it->lyxCode() == INCLUDE_CODE) {
|
||||||
InsetInclude & inset =
|
InsetInclude & inset =
|
||||||
static_cast<InsetInclude &>(*it);
|
static_cast<InsetInclude &>(*it);
|
||||||
inset.updateBibfilesCache();
|
Buffer const * const incbuf = inset.getChildBuffer();
|
||||||
|
if (!incbuf)
|
||||||
|
continue;
|
||||||
|
incbuf->updateBibfilesCache(UpdateChildOnly);
|
||||||
support::FileNameList const & bibfiles =
|
support::FileNameList const & bibfiles =
|
||||||
inset.getBibfilesCache();
|
incbuf->getBibfilesCache(UpdateChildOnly);
|
||||||
if (!bibfiles.empty()) {
|
if (!bibfiles.empty()) {
|
||||||
d->bibfiles_cache_.insert(d->bibfiles_cache_.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->bibinfo_cache_valid_ = false;
|
d->bibinfo_cache_valid_ = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
d->bibfile_cache_valid_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1737,6 +1745,11 @@ void Buffer::invalidateBibinfoCache()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Buffer::invalidateBibfileCache()
|
||||||
|
{
|
||||||
|
d->bibfile_cache_valid_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
support::FileNameList const & Buffer::getBibfilesCache(UpdateScope scope) const
|
support::FileNameList const & Buffer::getBibfilesCache(UpdateScope scope) const
|
||||||
{
|
{
|
||||||
// If this is a child document, use the parent's cache instead.
|
// If this is a child document, use the parent's cache instead.
|
||||||
@ -1744,9 +1757,8 @@ support::FileNameList const & Buffer::getBibfilesCache(UpdateScope scope) const
|
|||||||
if (pbuf && scope != UpdateChildOnly)
|
if (pbuf && scope != UpdateChildOnly)
|
||||||
return pbuf->getBibfilesCache();
|
return pbuf->getBibfilesCache();
|
||||||
|
|
||||||
// We update the cache when first used instead of at loading time.
|
if (!d->bibfile_cache_valid_)
|
||||||
if (d->bibfiles_cache_.empty())
|
this->updateBibfilesCache(scope);
|
||||||
const_cast<Buffer *>(this)->updateBibfilesCache(scope);
|
|
||||||
|
|
||||||
return d->bibfiles_cache_;
|
return d->bibfiles_cache_;
|
||||||
}
|
}
|
||||||
@ -1785,6 +1797,8 @@ void Buffer::checkBibInfoCache() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME Don't do this here, but instead gather them as we go through
|
||||||
|
// updateBuffer().
|
||||||
if (!d->bibinfo_cache_valid_) {
|
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)
|
||||||
|
@ -342,9 +342,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
void validate(LaTeXFeatures &) const;
|
void validate(LaTeXFeatures &) const;
|
||||||
|
|
||||||
/// Update the list of all bibfiles in use (including bibfiles
|
|
||||||
/// of loaded child documents).
|
|
||||||
void updateBibfilesCache(UpdateScope scope = UpdateMaster) const;
|
|
||||||
/// Return the list with all bibfiles in use (including bibfiles
|
/// Return the list with all bibfiles in use (including bibfiles
|
||||||
/// of loaded child documents).
|
/// of loaded child documents).
|
||||||
support::FileNameList const &
|
support::FileNameList const &
|
||||||
@ -354,6 +351,8 @@ public:
|
|||||||
/// Calling this method invalidates the cache and so requires a
|
/// Calling this method invalidates the cache and so requires a
|
||||||
/// re-read.
|
/// re-read.
|
||||||
void invalidateBibinfoCache();
|
void invalidateBibinfoCache();
|
||||||
|
/// This invalidates the cache of files we need to check.
|
||||||
|
void invalidateBibfileCache();
|
||||||
/// Updates the cached bibliography information.
|
/// Updates the cached bibliography information.
|
||||||
/// Note that you MUST call this method to update the cache. It will
|
/// Note that you MUST call this method to update the cache. It will
|
||||||
/// not happen otherwise. (Currently, it is called at the start of
|
/// not happen otherwise. (Currently, it is called at the start of
|
||||||
@ -579,6 +578,9 @@ private:
|
|||||||
bool fromString = false);
|
bool fromString = false);
|
||||||
///
|
///
|
||||||
void getLanguages(std::set<Language const *> &) const;
|
void getLanguages(std::set<Language const *> &) const;
|
||||||
|
/// Update the list of all bibfiles in use (including bibfiles
|
||||||
|
/// of loaded child documents).
|
||||||
|
void updateBibfilesCache(UpdateScope scope = UpdateMaster) const;
|
||||||
|
|
||||||
/// Use the Pimpl idiom to hide the internals.
|
/// Use the Pimpl idiom to hide the internals.
|
||||||
class Impl;
|
class Impl;
|
||||||
|
@ -1565,8 +1565,10 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
|||||||
InsetBibtex * inset = getInsetByCode<InsetBibtex>(tmpcur,
|
InsetBibtex * inset = getInsetByCode<InsetBibtex>(tmpcur,
|
||||||
BIBTEX_CODE);
|
BIBTEX_CODE);
|
||||||
if (inset) {
|
if (inset) {
|
||||||
if (inset->addDatabase(cmd.argument()))
|
if (inset->addDatabase(cmd.argument())) {
|
||||||
buffer_.updateBibfilesCache();
|
buffer_.invalidateBibfileCache();
|
||||||
|
dr.forceBufferUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1577,8 +1579,10 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
|||||||
InsetBibtex * inset = getInsetByCode<InsetBibtex>(tmpcur,
|
InsetBibtex * inset = getInsetByCode<InsetBibtex>(tmpcur,
|
||||||
BIBTEX_CODE);
|
BIBTEX_CODE);
|
||||||
if (inset) {
|
if (inset) {
|
||||||
if (inset->delDatabase(cmd.argument()))
|
if (inset->delDatabase(cmd.argument())) {
|
||||||
buffer_.updateBibfilesCache();
|
buffer_.invalidateBibfileCache();
|
||||||
|
dr.forceBufferUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,8 @@ void InsetBibtex::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
setParams(p);
|
setParams(p);
|
||||||
buffer().updateBibfilesCache();
|
buffer().invalidateBibfileCache();
|
||||||
|
cur.forceBufferUpdate();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_INSET_MODIFY: {
|
case LFUN_INSET_MODIFY: {
|
||||||
// It should be OK just to invalidate the cache is setParams()
|
// It should be OK just to invalidate the cache in setParams()
|
||||||
// If not....
|
// If not....
|
||||||
// child_buffer_ = 0;
|
// child_buffer_ = 0;
|
||||||
InsetCommandParams p(INCLUDE_CODE);
|
InsetCommandParams p(INCLUDE_CODE);
|
||||||
@ -338,7 +338,7 @@ void InsetInclude::setParams(InsetCommandParams const & p)
|
|||||||
if (type(params()) == INPUT)
|
if (type(params()) == INPUT)
|
||||||
add_preview(*preview_, *this, buffer());
|
add_preview(*preview_, *this, buffer());
|
||||||
|
|
||||||
buffer().updateBibfilesCache();
|
buffer().invalidateBibfileCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -842,26 +842,6 @@ void InsetInclude::fillWithBibKeys(BiblioInfo & keys,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetInclude::updateBibfilesCache()
|
|
||||||
{
|
|
||||||
Buffer const * const child = getChildBuffer();
|
|
||||||
if (child)
|
|
||||||
child->updateBibfilesCache(Buffer::UpdateChildOnly);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
support::FileNameList const &
|
|
||||||
InsetInclude::getBibfilesCache() const
|
|
||||||
{
|
|
||||||
Buffer const * const child = getChildBuffer();
|
|
||||||
if (child)
|
|
||||||
return child->getBibfilesCache(Buffer::UpdateChildOnly);
|
|
||||||
|
|
||||||
static support::FileNameList const empty;
|
|
||||||
return empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
|
void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||||
{
|
{
|
||||||
LASSERT(mi.base.bv, /**/);
|
LASSERT(mi.base.bv, /**/);
|
||||||
|
@ -61,20 +61,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
void fillWithBibKeys(BiblioInfo & keys, InsetIterator const & it) const;
|
void fillWithBibKeys(BiblioInfo & keys, InsetIterator const & it) const;
|
||||||
|
|
||||||
/** Update the cache with all bibfiles in use of the child buffer
|
|
||||||
* (including bibfiles of grandchild documents).
|
|
||||||
* Does nothing if the child document is not loaded to prevent
|
|
||||||
* automatic loading of all child documents upon loading the master.
|
|
||||||
* \param buffer the Buffer containing this inset.
|
|
||||||
*/
|
|
||||||
void updateBibfilesCache();
|
|
||||||
/** Return the cache with all bibfiles in use of the child buffer
|
|
||||||
* (including bibfiles of grandchild documents).
|
|
||||||
* Return an empty vector if the child doc is not loaded.
|
|
||||||
* \param buffer the Buffer containing this inset.
|
|
||||||
*/
|
|
||||||
support::FileNameList const &
|
|
||||||
getBibfilesCache() const;
|
|
||||||
///
|
///
|
||||||
bool hasSettings() const { return true; }
|
bool hasSettings() const { return true; }
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user