mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Do not scan BibTeX files multiple times in a collectBibKeys() procedure.
Scanning is rather slow, so this improves performance in specific situations (multiple inclusion of larger files in master/child or chapterbib context)
This commit is contained in:
parent
b4294a7b06
commit
88a0666d6c
@ -2446,15 +2446,16 @@ void Buffer::reloadBibInfoCache() const
|
||||
return;
|
||||
|
||||
d->bibinfo_.clear();
|
||||
collectBibKeys();
|
||||
FileNameList checkedFiles;
|
||||
collectBibKeys(checkedFiles);
|
||||
d->bibinfo_cache_valid_ = true;
|
||||
}
|
||||
|
||||
|
||||
void Buffer::collectBibKeys() const
|
||||
void Buffer::collectBibKeys(FileNameList & checkedFiles) const
|
||||
{
|
||||
for (InsetIterator it = inset_iterator_begin(inset()); it; ++it)
|
||||
it->collectBibKeys(it);
|
||||
it->collectBibKeys(it, checkedFiles);
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "support/unique_ptr.h"
|
||||
#include "support/strfwd.h"
|
||||
#include "support/types.h"
|
||||
#include "support/FileNameList.h"
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
@ -520,7 +521,7 @@ public:
|
||||
/// or just for it, if it isn't a child.
|
||||
BiblioInfo const & masterBibInfo() const;
|
||||
/// collect bibliography info from the various insets in this buffer.
|
||||
void collectBibKeys() const;
|
||||
void collectBibKeys(support::FileNameList &) const;
|
||||
/// add some BiblioInfo to our cache
|
||||
void addBiblioInfo(BiblioInfo const & bi) const;
|
||||
/// add a single piece of bibliography info to our cache
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "support/strfwd.h"
|
||||
#include "support/types.h"
|
||||
#include "support/FileNameList.h"
|
||||
|
||||
#include <climits>
|
||||
|
||||
@ -529,7 +530,7 @@ public:
|
||||
UpdateType /* utype*/,
|
||||
TocBackend & /* tocbackend */) const {}
|
||||
/// Collect BibTeX information
|
||||
virtual void collectBibKeys(InsetIterator const &) const {}
|
||||
virtual void collectBibKeys(InsetIterator const &, support::FileNameList &) const {}
|
||||
/// Update the counters of this inset and of its contents.
|
||||
/// The boolean indicates whether we are preparing for output, e.g.,
|
||||
/// of XHTML.
|
||||
|
@ -285,7 +285,7 @@ docstring bibitemWidest(Buffer const & buffer, OutputParams const & runparams)
|
||||
}
|
||||
|
||||
|
||||
void InsetBibitem::collectBibKeys(InsetIterator const & it) const
|
||||
void InsetBibitem::collectBibKeys(InsetIterator const & it, FileNameList & /*checkedFiles*/) const
|
||||
{
|
||||
docstring const key = getParam("key");
|
||||
docstring const label = getParam("label");
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
///
|
||||
docstring xhtml(XHTMLStream &, OutputParams const &) const;
|
||||
///
|
||||
void collectBibKeys(InsetIterator const &) const;
|
||||
void collectBibKeys(InsetIterator const &, support::FileNameList &) const;
|
||||
/// update the counter of this inset
|
||||
void updateBuffer(ParIterator const &, UpdateType);
|
||||
///@}
|
||||
|
@ -645,13 +645,13 @@ namespace {
|
||||
} // namespace
|
||||
|
||||
|
||||
void InsetBibtex::collectBibKeys(InsetIterator const & /*di*/) const
|
||||
void InsetBibtex::collectBibKeys(InsetIterator const & /*di*/, FileNameList & checkedFiles) const
|
||||
{
|
||||
parseBibTeXFiles();
|
||||
parseBibTeXFiles(checkedFiles);
|
||||
}
|
||||
|
||||
|
||||
void InsetBibtex::parseBibTeXFiles() const
|
||||
void InsetBibtex::parseBibTeXFiles(FileNameList & checkedFiles) const
|
||||
{
|
||||
// This bibtex parser is a first step to parse bibtex files
|
||||
// more precisely.
|
||||
@ -678,7 +678,14 @@ void InsetBibtex::parseBibTeXFiles() const
|
||||
support::FileNamePairList::const_iterator it = files.begin();
|
||||
support::FileNamePairList::const_iterator en = files.end();
|
||||
for (; it != en; ++ it) {
|
||||
ifdocstream ifs(it->second.toFilesystemEncoding().c_str(),
|
||||
FileName const bibfile = it->second;
|
||||
if (find(checkedFiles.begin(), checkedFiles.end(), bibfile) != checkedFiles.end())
|
||||
// already checked this one. Skip.
|
||||
continue;
|
||||
else
|
||||
// record that we check this.
|
||||
checkedFiles.push_back(bibfile);
|
||||
ifdocstream ifs(bibfile.toFilesystemEncoding().c_str(),
|
||||
ios_base::in, buffer().masterParams().encoding().iconvName());
|
||||
|
||||
char_type ch;
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
int plaintext(odocstringstream & ods, OutputParams const & op,
|
||||
size_t max_length = INT_MAX) const;
|
||||
///
|
||||
void collectBibKeys(InsetIterator const &) const;
|
||||
void collectBibKeys(InsetIterator const &, support::FileNameList &) const;
|
||||
///
|
||||
void validate(LaTeXFeatures &) const;
|
||||
///
|
||||
@ -84,7 +84,7 @@ private:
|
||||
///
|
||||
void editDatabases() const;
|
||||
///
|
||||
void parseBibTeXFiles() const;
|
||||
void parseBibTeXFiles(support::FileNameList &) const;
|
||||
///
|
||||
bool usingBiblatex() const;
|
||||
|
||||
|
@ -1072,7 +1072,7 @@ void InsetInclude::validate(LaTeXFeatures & features) const
|
||||
}
|
||||
|
||||
|
||||
void InsetInclude::collectBibKeys(InsetIterator const & /*di*/) const
|
||||
void InsetInclude::collectBibKeys(InsetIterator const & /*di*/, FileNameList & checkedFiles) const
|
||||
{
|
||||
Buffer * child = loadIfNeeded();
|
||||
if (!child)
|
||||
@ -1082,7 +1082,7 @@ void InsetInclude::collectBibKeys(InsetIterator const & /*di*/) const
|
||||
// But it'll have to do for now.
|
||||
if (child == &buffer())
|
||||
return;
|
||||
child->collectBibKeys();
|
||||
child->collectBibKeys(checkedFiles);
|
||||
}
|
||||
|
||||
|
||||
|
@ -92,7 +92,7 @@ public:
|
||||
* \param keys the list of bibkeys in the child buffer.
|
||||
* \param it not used here
|
||||
*/
|
||||
void collectBibKeys(InsetIterator const &) const;
|
||||
void collectBibKeys(InsetIterator const &, support::FileNameList &) const;
|
||||
///
|
||||
bool hasSettings() const { return true; }
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user