From 66a97007eb36a112f31e923c20e434ba8b39c4ba Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 16 Oct 2020 03:49:52 +0200 Subject: Matrix: use rapidjson instead of jsoncpp to decrease memory usage from 58mb to 24mb --- plugins/Matrix.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'plugins') diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp index 5819420..09895b0 100644 --- a/plugins/Matrix.hpp +++ b/plugins/Matrix.hpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include namespace QuickMedia { // Dummy, only play one video. TODO: Play all videos in room, as related videos? @@ -150,19 +150,19 @@ namespace QuickMedia { bool use_tor = false; private: - PluginResult sync_response_to_body_items(const Json::Value &root, RoomSyncMessages &room_messages); + PluginResult sync_response_to_body_items(const rapidjson::Document &root, RoomSyncMessages &room_messages); PluginResult get_previous_room_messages(std::shared_ptr &room_data); - void events_add_user_info(const Json::Value &events_json, RoomData *room_data); - void events_add_user_read_markers(const Json::Value &events_json, RoomData *room_data); - void events_add_messages(const Json::Value &events_json, std::shared_ptr &room_data, MessageDirection message_dir, RoomSyncMessages *room_messages, bool has_unread_notifications); - void events_set_room_name(const Json::Value &events_json, RoomData *room_data); + void events_add_user_info(const rapidjson::Value &events_json, RoomData *room_data); + void events_add_user_read_markers(const rapidjson::Value &events_json, RoomData *room_data); + void events_add_messages(const rapidjson::Value &events_json, std::shared_ptr &room_data, MessageDirection message_dir, RoomSyncMessages *room_messages, bool has_unread_notifications); + void events_set_room_name(const rapidjson::Value &events_json, RoomData *room_data); PluginResult upload_file(const std::string &room_id, const std::string &filepath, UploadInfo &file_info, UploadInfo &thumbnail_info, std::string &err_msg); std::shared_ptr get_edited_message_original_message(RoomData *room_data, std::shared_ptr message); std::shared_ptr get_room_by_id(const std::string &id); void add_room(std::shared_ptr room); - DownloadResult download_json(Json::Value &result, const std::string &url, std::vector additional_args, bool use_browser_useragent = false, std::string *err_msg = nullptr) const; + DownloadResult download_json(rapidjson::Document &result, const std::string &url, std::vector additional_args, bool use_browser_useragent = false, std::string *err_msg = nullptr) const; private: std::unordered_map> room_data_by_id; std::mutex room_data_mutex; -- cgit v1.2.3