mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 19:11:39 -06:00
While testing the original database from issue #1892 which contains hundreds of tables and fields, I noticed how long the loading of the database structure takes. This is especially problematic since it needs to be reloaded on various occasions, e.g. running most statements in the Execute SQL tab, which stalls the application every time. According to a profiler it is the QIcon constructor which requires most of the time. By introducing this small icon cache class we can reduce the time for loading icons to almost nothing. While still not perfect the UI already feels much more responsive with this patch.
22 lines
316 B
C++
22 lines
316 B
C++
#ifndef ICONCACHE_H
|
|
#define ICONCACHE_H
|
|
|
|
#include <QIcon>
|
|
|
|
#include <string>
|
|
#include <unordered_map>
|
|
|
|
class IconCache
|
|
{
|
|
public:
|
|
IconCache() = delete;
|
|
|
|
static const QIcon& get(const std::string& name);
|
|
|
|
private:
|
|
static QIcon null_icon;
|
|
static std::unordered_map<std::string, QIcon> icons;
|
|
};
|
|
|
|
#endif
|