From 872c71ffa61e52918a12c847ef7f87b10741d75a Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Sat, 9 Mar 2013 12:42:56 -0500 Subject: [PATCH] Try again to fix Kornel's slowness problem. The previous attempt was worth doing, as we were creating too much output for tooltips anyway. But we need to ignore BibTeX insets altogether, as the collection of the references, etc, is too slow. --- src/insets/InsetBibtex.cpp | 11 ++++++++--- src/insets/InsetExternal.cpp | 4 ++++ src/insets/InsetInclude.cpp | 18 ++++++++++++------ src/mathed/InsetFormulaMacro.cpp | 2 +- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index 0392b9d233..70174730b9 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -929,16 +929,21 @@ void InsetBibtex::validate(LaTeXFeatures & features) const int InsetBibtex::plaintext(odocstringstream & os, - OutputParams const &, size_t max_length) const + OutputParams const & op, size_t max_length) const { + docstring const reflabel = buffer().B_("References"); + + if (op.for_tooltip || op.for_toc) { + os << reflabel; + return reflabel.size(); + } + BiblioInfo bibinfo = buffer().masterBibInfo(); bibinfo.makeCitationLabels(buffer()); vector const & cites = bibinfo.citedEntries(); size_t start_size = os.str().size(); docstring refoutput; - docstring const reflabel = buffer().B_("References"); - refoutput += reflabel + "\n\n"; // Now we loop over the entries diff --git a/src/insets/InsetExternal.cpp b/src/insets/InsetExternal.cpp index e73a6c02f6..6c38e1f3a6 100644 --- a/src/insets/InsetExternal.cpp +++ b/src/insets/InsetExternal.cpp @@ -694,6 +694,10 @@ void InsetExternal::latex(otexstream & os, OutputParams const & runparams) const int InsetExternal::plaintext(odocstringstream & os, OutputParams const & runparams, size_t) const { + // this is too slow for constant use + if (runparams.for_tooltip) + return 0; + os << '\n'; // output external material on a new line external::writeExternal(params_, "Ascii", buffer(), os, *(runparams.exportdata), false, diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index 70050fd5bc..c3bd9197ea 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -813,12 +813,18 @@ docstring InsetInclude::xhtml(XHTMLStream & xs, OutputParams const & rp) const int InsetInclude::plaintext(odocstringstream & os, OutputParams const & op, size_t) const { - // don't write the file just because we're making a tooltip or toc entry!! - if (op.for_tooltip || op.for_toc || isVerbatim(params()) || isListings(params())) { - os << '[' << screenLabel() << '\n'; - // FIXME: We don't know the encoding of the file, default to UTF-8. - os << includedFileName(buffer(), params()).fileContents("UTF-8"); - os << "\n]"; + // just write the filename if we're making a tooltip or toc entry + if (op.for_tooltip || op.for_toc) { + os << '[' << screenLabel() << '\n' + << getParam("filename") << "\n]"; + return PLAINTEXT_NEWLINE + 1; // one char on a separate line + } + + if (isVerbatim(params()) || isListings(params())) { + os << '[' << screenLabel() << '\n' + // FIXME: We don't know the encoding of the file, default to UTF-8. + << includedFileName(buffer(), params()).fileContents("UTF-8") + << "\n]"; return PLAINTEXT_NEWLINE + 1; // one char on a separate line } diff --git a/src/mathed/InsetFormulaMacro.cpp b/src/mathed/InsetFormulaMacro.cpp index 88b54c28c5..88897021fe 100644 --- a/src/mathed/InsetFormulaMacro.cpp +++ b/src/mathed/InsetFormulaMacro.cpp @@ -84,7 +84,7 @@ void InsetFormulaMacro::latex(otexstream & os, } -int InsetFormulaMacro::plaintext(odocstringstream & os, OutputParams const & runparams, int max_length) const +int InsetFormulaMacro::plaintext(odocstringstream & os, OutputParams const & runparams, size_t) const { odocstringstream oss; WriteStream wi(oss, false, true, WriteStream::wsDefault, runparams.encoding); -- 2.39.2