VSpace defskip;
PDFOptions pdfoptions;
LayoutFileIndex baseClass_;
+ /// Caching for exportableFormats, which seems to be slow.
+ std::vector<Format const *> exportableFormatList;
+ std::vector<Format const *> viewableFormatList;
+ bool isViewCacheValid;
+ bool isExportCacheValid;
};
BufferParams::Impl::Impl()
- : defskip(VSpace::MEDSKIP), baseClass_(string(""))
+ : defskip(VSpace::MEDSKIP), baseClass_(string("")),
+ isViewCacheValid(false), isExportCacheValid(false)
{
// set initial author
// FIXME UNICODE
{
// evil, but this function is evil
doc_class_ = const_pointer_cast<DocumentClass>(tc);
+ invalidateConverterCache();
}
if (!baseClass())
return;
+ invalidateConverterCache();
LayoutModuleList mods;
LayoutModuleList::iterator it = layout_modules_.begin();
LayoutModuleList::iterator en = layout_modules_.end();
}
-vector<Format const *> BufferParams::exportableFormats(bool only_viewable) const
+vector<Format const *> const & BufferParams::exportableFormats(bool only_viewable) const
{
+ vector<Format const *> & cached = only_viewable ?
+ pimpl_->viewableFormatList : pimpl_->exportableFormatList;
+ bool & valid = only_viewable ?
+ pimpl_->isViewCacheValid : pimpl_->isExportCacheValid;
+ if (valid)
+ return cached;
+
vector<string> const backs = backends();
set<string> excludes;
if (useNonTeXFonts) {
theConverters().getReachable(*it, only_viewable, false, excludes);
result.insert(result.end(), r.begin(), r.end());
}
- return result;
+ cached = result;
+ valid = true;
+ return cached;
}
bool BufferParams::isExportableFormat(string const & format) const
{
typedef vector<Format const *> Formats;
- Formats formats;
- formats = exportableFormats(true);
+ Formats const & formats = exportableFormats(true);
Formats::const_iterator fit = formats.begin();
Formats::const_iterator end = formats.end();
for (; fit != end ; ++fit) {
return default_output_format;
if (isDocBook()
|| encoding().package() == Encoding::japanese) {
- vector<Format const *> const formats = exportableFormats(true);
+ vector<Format const *> const & formats = exportableFormats(true);
if (formats.empty())
return string();
// return the first we find
return styles;
}
+void BufferParams::invalidateConverterCache() const
+{
+ pimpl_->isExportCacheValid = false;
+ pimpl_->isViewCacheValid = false;
+}
+
} // namespace lyx
///
bool isExportable(std::string const & format) const;
///
- std::vector<Format const *> exportableFormats(bool only_viewable) const;
+ std::vector<const Format *> const & exportableFormats(bool only_viewable) const;
///
bool isExportableFormat(std::string const & format) const;
/// the backends appropriate for use with this document.
/// Return true if language could be set to lang,
/// otherwise return false and do not change language
bool setLanguage(std::string const & lang);
+ ///
+ void invalidateConverterCache() const;
private:
///
* mathdots, stackrel, stmaryrd and undertilde.
*/
PackageMap use_packages;
-
+
/** Use the Pimpl idiom to hide those member variables that would otherwise
* drag in other header files.
*/