mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-20 11:48:30 -06:00
Test features to see if they're already set before setting them.
Setting a feature writes to KVP which in the SQL backend causes the book to be written out, which is rather expensive. Doing this in a loop (as is the case in convert_imap_account, is quite slow, and this change afforded a 4x speedup.
This commit is contained in:
parent
4fc61b2ac8
commit
82d891a202
@ -1144,10 +1144,20 @@ void
|
||||
qof_book_set_feature (QofBook *book, const gchar *key, const gchar *descr)
|
||||
{
|
||||
KvpFrame *frame = qof_instance_get_slots (QOF_INSTANCE (book));
|
||||
qof_book_begin_edit (book);
|
||||
delete frame->set_path({GNC_FEATURES, key}, new KvpValue(descr));
|
||||
qof_instance_set_dirty (QOF_INSTANCE (book));
|
||||
qof_book_commit_edit (book);
|
||||
KvpValue* feature = nullptr;
|
||||
auto feature_slot = frame->get_slot(GNC_FEATURES);
|
||||
if (feature_slot)
|
||||
{
|
||||
auto feature_frame = feature_slot->get<KvpFrame*>();
|
||||
feature = feature_frame->get_slot(key);
|
||||
}
|
||||
if (feature == nullptr || g_strcmp0 (feature->get<const char*>(), descr))
|
||||
{
|
||||
qof_book_begin_edit (book);
|
||||
delete frame->set_path({GNC_FEATURES, key}, new KvpValue(descr));
|
||||
qof_instance_set_dirty (QOF_INSTANCE (book));
|
||||
qof_book_commit_edit (book);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user