From b79bd701400fb8bf8a845f8a24d78e82f182bb2f Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Sat, 26 May 2018 17:46:51 +0900 Subject: Improve performance --- src/TgTypeParser.cpp | 102 +++++++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) (limited to 'src/TgTypeParser.cpp') diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp index 84a83df..1b80d7f 100644 --- a/src/TgTypeParser.cpp +++ b/src/TgTypeParser.cpp @@ -33,7 +33,7 @@ TgTypeParser& TgTypeParser::getInstance() { } Chat::Ptr TgTypeParser::parseJsonAndGetChat(const ptree& data) const { - Chat::Ptr result(new Chat); + auto result(make_shared()); result->id = data.get("id"); string type = data.get("type"); if (type == "private") { @@ -80,7 +80,7 @@ string TgTypeParser::parseChat(const Chat::Ptr& object) const { } User::Ptr TgTypeParser::parseJsonAndGetUser(const ptree& data) const { - User::Ptr result(new User); + auto result(make_shared()); result->id = data.get("id"); result->firstName = data.get("first_name"); result->lastName = data.get("last_name", ""); @@ -104,7 +104,7 @@ string TgTypeParser::parseUser(const User::Ptr& object) const { } MessageEntity::Ptr TgTypeParser::parseJsonAndGetEntity(const ptree& data) const{ - MessageEntity::Ptr result(new MessageEntity); + auto result(make_shared()); result->type=data.get("type"); result->offset=data.get("offset"); result->length=data.get("length"); @@ -114,7 +114,7 @@ MessageEntity::Ptr TgTypeParser::parseJsonAndGetEntity(const ptree& data) const{ } Message::Ptr TgTypeParser::parseJsonAndGetMessage(const ptree& data) const { - Message::Ptr result(new Message); + auto result(make_shared()); result->messageId = data.get("message_id"); result->from = tryParseJson(&TgTypeParser::parseJsonAndGetUser, data, "from"); result->date = data.get("date"); @@ -189,7 +189,7 @@ string TgTypeParser::parseMessage(const Message::Ptr& object) const { } PhotoSize::Ptr TgTypeParser::parseJsonAndGetPhotoSize(const ptree& data) const { - PhotoSize::Ptr result(new PhotoSize); + auto result(make_shared()); result->fileId = data.get("file_id"); result->width = data.get("width"); result->height = data.get("height"); @@ -213,7 +213,7 @@ string TgTypeParser::parsePhotoSize(const PhotoSize::Ptr& object) const { } Audio::Ptr TgTypeParser::parseJsonAndGetAudio(const ptree& data) const { - Audio::Ptr result(new Audio); + auto result(make_shared