On 09/01/2018 01:36 PM, Richard Kimberly Heck wrote: > On 09/01/2018 12:58 PM, Richard Kimberly Heck wrote: >> On 09/01/2018 10:02 AM, Jürgen Spitzmüller wrote: >>> Am Samstag, den 01.09.2018, 13:49 +0200 schrieb Enrico Forestieri: >>>> Using the --verbose switch it can be seen that each time a new >>>> paragraph >>>> is started LyX runs kpsewhich for each bibtex catalog to be found in >>>> the >>>> texmf tree. So, if you have 5 catalogs, kpsewhich is run for 5 times >>>> everytime you hit the Enter key. >>> Indeed, that's likely the culprit. >>> >>> The call is in InsetBibtex::getBibTeXPath(), which is called by >>> InsetBibtex::getBibFiles(), which is called by >>> InsetBibTeX::updateBuffer(), which is called by Buffer::updateBuffer() >>> >>> Would it make sense to cache those paths, too? After all, they are >>> unlikely to change that often. >> Weird that no-one saw this problem on Linux. > Here's a simple patch which would need a bit of additional work, but can > be a kind of proof of concept (and be tested). Comments?
Updated patch. Riki
commit 995e5ddaa031931bad121fa597a8f84b73371c49 Author: Richard Kimberly Heck <rikih...@lyx.org> Date: Sat Sep 1 15:16:01 2018 -0400 Fix slowness on Windows. See bug #9158. diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 8ca74103a2..bbcbd9c62c 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -143,7 +143,6 @@ typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache; // A storehouse for the cloned buffers. list<CloneList *> cloned_buffers; - class Buffer::Impl { public: @@ -2438,6 +2437,31 @@ void Buffer::registerBibfiles(FileNamePairList const & bf) const } +static map<docstring, FileName> bibfileCache; + + +bool Buffer::bibCacheHasFile(docstring const & bibid) +{ + map<docstring, FileName>::const_iterator it = + bibfileCache.find(bibid); + return it != bibfileCache.end(); +} + + +void Buffer::updateBibCacheFileName(docstring const & bibid, + support::FileName const & fn) +{ + bibfileCache[bibid] = fn; +} + + +FileName Buffer::getBibCacheFileName(docstring const & bibid) +{ + LASSERT(bibCacheHasFile(bibid), return FileName()); + return bibfileCache[bibid]; +} + + void Buffer::checkIfBibInfoCacheIsValid() const { // use the master's cache diff --git a/src/Buffer.h b/src/Buffer.h index 50d086f287..2f287a2c57 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -766,6 +766,13 @@ public: void updateChangesPresent() const; /// void registerBibfiles(support::FileNamePairList const & bf) const; + /// + static bool bibCacheHasFile(docstring const & bibid); + /// will add or update as required + static void updateBibCacheFileName(docstring const & bibid, + support::FileName const & fn); + /// + static support::FileName getBibCacheFileName(docstring const & bibid); private: friend class MarkAsExporting; diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index d2e7284052..03cd44c8a5 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -397,7 +397,13 @@ FileNamePairList InsetBibtex::getBibFiles() const vector<docstring>::const_iterator it = bibfilelist.begin(); vector<docstring>::const_iterator en = bibfilelist.end(); for (; it != en; ++it) { - FileName const file = getBibTeXPath(*it, buffer()); + FileName file; + if (buffer().bibCacheHasFile(*it)) { + file = buffer().getBibCacheFileName(*it); + } else { + file = getBibTeXPath(*it, buffer()); + buffer().updateBibCacheFileName(*it, file); + } if (!file.empty()) vec.push_back(make_pair(*it, file));