From: Richard Kimberly Heck Date: Fri, 14 Dec 2018 15:55:16 +0000 (-0500) Subject: Fix slowness problem on Windows reported on the list. X-Git-Tag: lyx-2.4.0dev-acb2ca7b~2878 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=577746ad9294abe688f0738c363f534b5e3810be;p=lyx.git Fix slowness problem on Windows reported on the list. https://marc.info/?l=lyx-devel&m=154458979925296&w=2 This is related to the fix for #9158 and the caching of bibfile information. On Windows, it is incredibly slow to run kpsewhich, which we do to check where files actually are, so as to get info about them (e.g., timestamps). So we have started to cache that as a map. The map is supposed to be invalidated when various things happen, but an oversight was causing it to be invalidated on every cut operation. This is because cutting uses a temporary Buffer, and the operations on it were affecting the *global* cache of biblio file info. (It makes sense to have a global cache, since these files are not document-specific.) Basically, we have to update the list of bibfiles in that temporary Buffer---but that is one of the things that invalidated the cache. The solution is only to invalidate the cache if the list of bibfiles has actually changed (a sensible idea anyway). The only time that will happen in the temporary Buffer is when the copied information contains a BibTeX inset. That should be fairly rare. --- diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 1f6436662d..eff76bf1e8 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -2480,6 +2480,10 @@ void Buffer::checkIfBibInfoCacheIsValid() const if (!d->bibinfo_cache_valid_) return; + // we'll assume it's ok and change this if it's not + d->bibinfo_cache_valid_ = true; + d->cite_labels_valid_ = true; + // compare the cached timestamps with the actual ones. docstring_list const & bibfiles_cache = getBibfiles(); for (auto const & bf : bibfiles_cache) { @@ -2503,6 +2507,10 @@ void Buffer::clearBibFileCache() const void Buffer::reloadBibInfoCache(bool const force) const { + // we should not need to do this for internal buffers + if (isInternal()) + return; + // use the master's cache Buffer const * const tmp = masterBuffer(); if (tmp != this) { @@ -2516,6 +2524,7 @@ void Buffer::reloadBibInfoCache(bool const force) const return; } + LYXERR(Debug::FILES, "Bibinfo cache was invalid."); // re-read file locations when this info changes // FIXME Is this sufficient? Or should we also force that // in some other cases? If so, then it is easy enough to