diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-05-30 01:09:16 +0200 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-05-30 01:09:16 +0200 |
commit | 567078d39f3c85f260efd68aeb5c99f8e4ffe348 (patch) | |
tree | 759ac4f2ec0f7c47cebb0cf3e013d377a936fabe /src/timeline | |
parent | Optimize completion model by only splitting on normal spaces (diff) | |
download | nheko-567078d39f3c85f260efd68aeb5c99f8e4ffe348.tar.xz |
Try to get rid of an allocation
Diffstat (limited to 'src/timeline')
-rw-r--r-- | src/timeline/EventStore.cpp | 14 | ||||
-rw-r--r-- | src/timeline/EventStore.h | 2 | ||||
-rw-r--r-- | src/timeline/TimelineModel.cpp | 4 |
3 files changed, 9 insertions, 11 deletions
diff --git a/src/timeline/EventStore.cpp b/src/timeline/EventStore.cpp index 883d384c..4a9f0fff 100644 --- a/src/timeline/EventStore.cpp +++ b/src/timeline/EventStore.cpp @@ -770,7 +770,7 @@ EventStore::decryptEvent(const IdIndex &idx, } mtx::events::collections::TimelineEvents * -EventStore::get(std::string_view id, std::string_view related_to, bool decrypt, bool resolve_edits) +EventStore::get(std::string id, std::string_view related_to, bool decrypt, bool resolve_edits) { if (this->thread() != QThread::currentThread()) nhlog::db()->warn("{} called from a different thread!", __func__); @@ -778,7 +778,7 @@ EventStore::get(std::string_view id, std::string_view related_to, bool decrypt, if (id.empty()) return nullptr; - IdIndex index{room_id_, std::string(id)}; + IdIndex index{room_id_, std::move(id)}; if (resolve_edits) { auto edits_ = edits(index.id); if (!edits_.empty()) { @@ -796,14 +796,12 @@ EventStore::get(std::string_view id, std::string_view related_to, bool decrypt, http::client()->get_event( room_id_, index.id, - [this, - relatedTo = std::string(related_to.data(), related_to.size()), - id = index.id](const mtx::events::collections::TimelineEvents &timeline, - mtx::http::RequestErr err) { + [this, relatedTo = std::string(related_to), id = index.id]( + const mtx::events::collections::TimelineEvents &timeline, + mtx::http::RequestErr err) { if (err) { nhlog::net()->error( - "Failed to retrieve event with id {}, which " - "was " + "Failed to retrieve event with id {}, which was " "requested to show the replyTo for event {}", relatedTo, id); diff --git a/src/timeline/EventStore.h b/src/timeline/EventStore.h index c7a7588b..d9bb86cb 100644 --- a/src/timeline/EventStore.h +++ b/src/timeline/EventStore.h @@ -70,7 +70,7 @@ public: // optionally returns the event or nullptr and fetches it, after which it emits a // relatedFetched event - mtx::events::collections::TimelineEvents *get(std::string_view id, + mtx::events::collections::TimelineEvents *get(std::string id, std::string_view related_to, bool decrypt = true, bool resolve_edits = true); diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 8f4a8564..cd3febd5 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -574,7 +574,7 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r !event_id(event).empty() && event_id(event).front() == '$'); case IsEncrypted: { auto id = event_id(event); - auto encrypted_event = events.get(id, id, false); + auto encrypted_event = events.get(id, "", false); return encrypted_event && std::holds_alternative< mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>( @@ -583,7 +583,7 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r case Trustlevel: { auto id = event_id(event); - auto encrypted_event = events.get(id, id, false); + auto encrypted_event = events.get(id, "", false); if (encrypted_event) { if (auto encrypted = std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>( |