From 9ee9661bf3616603d9d92590fa1556840fe18970 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Sun, 14 Jul 2019 13:22:13 +0200 Subject: Optimizations: Database indices, cache id-Jid instead of id-jid_string, join real_jid on get messages --- libdino/src/entity/conversation.vala | 2 +- libdino/src/entity/file_transfer.vala | 3 +-- libdino/src/entity/message.vala | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'libdino/src/entity') diff --git a/libdino/src/entity/conversation.vala b/libdino/src/entity/conversation.vala index 0537ee61..53c59bd2 100644 --- a/libdino/src/entity/conversation.vala +++ b/libdino/src/entity/conversation.vala @@ -54,7 +54,7 @@ public class Conversation : Object { type_ = (Conversation.Type) row[db.conversation.type_]; account = db.get_account_by_id(row[db.conversation.account_id]); string? resource = row[db.conversation.resource]; - counterpart = Jid.parse(db.get_jid_by_id(row[db.conversation.jid_id])); + counterpart = db.get_jid_by_id(row[db.conversation.jid_id]); if (type_ == Conversation.Type.GROUPCHAT_PM) counterpart = counterpart.with_resource(resource); nickname = type_ == Conversation.Type.GROUPCHAT ? resource : null; active = row[db.conversation.active]; diff --git a/libdino/src/entity/file_transfer.vala b/libdino/src/entity/file_transfer.vala index 4e4103b9..9c0099d0 100644 --- a/libdino/src/entity/file_transfer.vala +++ b/libdino/src/entity/file_transfer.vala @@ -70,9 +70,8 @@ public class FileTransfer : Object { id = row[db.file_transfer.id]; account = db.get_account_by_id(row[db.file_transfer.account_id]); // TODO don’t have to generate acc new - string counterpart_jid = db.get_jid_by_id(row[db.file_transfer.counterpart_id]); + counterpart = db.get_jid_by_id(row[db.file_transfer.counterpart_id]); string counterpart_resource = row[db.file_transfer.counterpart_resource]; - counterpart = Jid.parse(counterpart_jid); if (counterpart_resource != null) counterpart = counterpart.with_resource(counterpart_resource); string our_resource = row[db.file_transfer.our_resource]; diff --git a/libdino/src/entity/message.vala b/libdino/src/entity/message.vala index a93b37ac..9a25ac0c 100644 --- a/libdino/src/entity/message.vala +++ b/libdino/src/entity/message.vala @@ -67,7 +67,7 @@ public class Message : Object { stanza_id = row[db.message.stanza_id]; type_ = (Message.Type) row[db.message.type_]; - counterpart = Jid.parse(db.get_jid_by_id(row[db.message.counterpart_id])); + counterpart = db.get_jid_by_id(row[db.message.counterpart_id]); string counterpart_resource = row[db.message.counterpart_resource]; if (counterpart_resource != null) counterpart = counterpart.with_resource(counterpart_resource); @@ -85,7 +85,7 @@ public class Message : Object { body = row[db.message.body]; marked = (Message.Marked) row[db.message.marked]; encryption = (Encryption) row[db.message.encryption]; - string? real_jid_str = db.real_jid.select({db.real_jid.real_jid}).with(db.real_jid.message_id, "=", id)[db.real_jid.real_jid]; + string? real_jid_str = row[db.real_jid.real_jid]; if (real_jid_str != null) real_jid = new Jid(real_jid_str); notify.connect(on_update); -- cgit v1.2.3-70-g09d2