mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-28 20:00:24 -07:00
* [Card Database] Improve loading times through binary cache Took 10 minutes Took 9 minutes Took 16 seconds * [Card Database] Remove lib qt include Took 18 minutes Took 14 seconds * Downgrade to 6.3 datastream Took 5 minutes * go up to 6.4 datastream Took 1 minute * Address comments * Small bug fixes Took 20 minutes Took 10 seconds * More fixes. Took 4 minutes Took 4 seconds * Even more fixes. Took 11 minutes Took 4 seconds * More fixes. Took 6 minutes Took 26 seconds Took 8 minutes * Namespace instead of class Took 6 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
50 lines
1.6 KiB
C++
50 lines
1.6 KiB
C++
/**
|
|
* @file card_database_settings.h
|
|
* @ingroup CardDatabase
|
|
* @ingroup CardSettings
|
|
*/
|
|
//! \todo Document this file.
|
|
|
|
#ifndef CARDDATABASESETTINGS_H
|
|
#define CARDDATABASESETTINGS_H
|
|
|
|
#include "settings_manager.h"
|
|
|
|
#include <QHash>
|
|
#include <QMutex>
|
|
#include <libcockatrice/interfaces/interface_card_set_priority_controller.h>
|
|
|
|
class CardDatabaseSettings : public SettingsManager, public ICardSetPriorityController
|
|
{
|
|
Q_OBJECT
|
|
friend class SettingsCache;
|
|
|
|
public:
|
|
void setSortKey(QString shortName, unsigned int sortKey) override;
|
|
void setEnabled(QString shortName, bool enabled) override;
|
|
void setIsKnown(QString shortName, bool isknown) override;
|
|
|
|
unsigned int getSortKey(QString shortName) const override;
|
|
bool isEnabled(QString shortName) const override;
|
|
bool isKnown(QString shortName) const override;
|
|
|
|
SetOptions getSetOptions(QString shortName) const override;
|
|
|
|
void saveSets(const QVector<SetSaveData> &data) override;
|
|
|
|
private:
|
|
explicit CardDatabaseSettings(const QString &settingPath, QObject *parent = nullptr);
|
|
|
|
// In-memory cache of set priority options. QSettings re-opens and re-parses
|
|
// the whole .ini on every access, which is catastrophic when CardSet
|
|
// construction calls getSortKey/isEnabled/isKnown once per set during the
|
|
// database load (thousands of file parses). The cache is populated from a
|
|
// single QSettings session and kept consistent with the writes below.
|
|
mutable QMutex setOptionsMutex;
|
|
mutable QHash<QString, SetOptions> setOptionsCache;
|
|
mutable bool setOptionsLoaded = false;
|
|
|
|
void ensureSetOptionsLoaded() const;
|
|
};
|
|
|
|
#endif // CARDDATABASESETTINGS_H
|