mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Perf comments: getFormatFromFile slows LyX startup considerably
It is currently called on hundreds of files: settings, layouts, icons, cached graphics files (incl. graphics from files that are not opened on startup). According to callgrind, fixing the FIXME comments could speed up startup by more than 30%.
This commit is contained in:
parent
22d7ba6424
commit
0a8b7f6a57
@ -159,6 +159,10 @@ void ConverterCache::Impl::readIndex()
|
||||
FormatCache & format_cache = cache[orig_from_name];
|
||||
if (format_cache.from_format.empty())
|
||||
format_cache.from_format =
|
||||
// FIXME perf: This very expensive function is called on all
|
||||
// cached files on opening. This slows LyX startup a lot. It
|
||||
// would be better if this information was retrieved in a
|
||||
// delayed fashion.
|
||||
formats.getFormatFromFile(orig_from_name);
|
||||
format_cache.cache[to_format] = item;
|
||||
}
|
||||
|
@ -531,6 +531,10 @@ bool Formats::isZippedFile(support::FileName const & filename) const {
|
||||
map<string, ZippedInfo>::iterator it = zipped_.find(fname);
|
||||
if (it != zipped_.end() && it->second.timestamp == timestamp)
|
||||
return it->second.zipped;
|
||||
// FIXME perf: This very expensive function is called on startup on each
|
||||
// file whic is going to be parsed, and also on svgz icons. Maybe there is a
|
||||
// quicker way to check whether a file is zipped? I.e. for icons we
|
||||
// probably just need to check the extension (svgz vs svg).
|
||||
string const & format = getFormatFromFile(filename);
|
||||
bool zipped = (format == "gzip" || format == "zip");
|
||||
zipped_.insert(make_pair(fname, ZippedInfo(zipped, timestamp)));
|
||||
|
@ -153,6 +153,7 @@ public:
|
||||
* fails, from file extension.
|
||||
* \returns file format if it could be found, otherwise an empty
|
||||
* string.
|
||||
* This function is expensive.
|
||||
*/
|
||||
std::string getFormatFromFile(support::FileName const & filename) const;
|
||||
/// Finds a format from a file extension. Returns string() if not found.
|
||||
|
Loading…
Reference in New Issue
Block a user