Skip to content

Commit

Permalink
pki_base: cache the hash
Browse files Browse the repository at this point in the history
It will not change for the lifetime of the item.
  • Loading branch information
chris2511 committed Jan 20, 2024
1 parent b6ce91b commit 2f482fc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/pki_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,9 @@ unsigned pki_base::hash(const QByteArray &ba)
}
unsigned pki_base::hash() const
{
return hash(i2d());
if (!hashcache)
hashcache = hash(i2d());
return hashcache;
}

QString pki_base::get_dump_filename(const QString &dir,
Expand Down
2 changes: 2 additions & 0 deletions lib/pki_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class pki_base : public QObject
{
Q_OBJECT

mutable unsigned hashcache{};

public: /* static */
static QRegularExpression limitPattern;
static QString rmslashdot(const QString &fname);
Expand Down

0 comments on commit 2f482fc

Please sign in to comment.