From d66e57a3afe416a0eaf950fdc0d374e6cb677038 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 25 Oct 2019 17:46:35 +0300 Subject: [PATCH] Remove redundabt web_location_flag_. GitOrigin-RevId: 0f24358ab873d2d49ef115ab9dbcdf86c72e0c7e --- td/telegram/files/FileLocation.h | 8 ++------ td/telegram/files/FileLocation.hpp | 12 ++++++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/td/telegram/files/FileLocation.h b/td/telegram/files/FileLocation.h index 8a87f86c8..3cbb2af40 100644 --- a/td/telegram/files/FileLocation.h +++ b/td/telegram/files/FileLocation.h @@ -183,7 +183,6 @@ class FullRemoteFileLocation { private: static constexpr int32 WEB_LOCATION_FLAG = 1 << 24; static constexpr int32 FILE_REFERENCE_FLAG = 1 << 25; - bool web_location_flag_{false}; DcId dc_id_; string file_reference_; enum class LocationType : int32 { Web, Photo, Common, None }; @@ -361,7 +360,7 @@ class FullRemoteFileLocation { } bool is_web() const { - return web_location_flag_; + return variant_.get_offset() == 0; } bool is_photo() const { return location_type() == LocationType::Photo; @@ -502,10 +501,7 @@ class FullRemoteFileLocation { // web document FullRemoteFileLocation(FileType file_type, string url, int64 access_hash) - : file_type_(file_type) - , web_location_flag_{true} - , dc_id_() - , variant_(WebRemoteFileLocation{std::move(url), access_hash}) { + : file_type_(file_type), dc_id_(), variant_(WebRemoteFileLocation{std::move(url), access_hash}) { CHECK(is_web()); CHECK(!web().url_.empty()); } diff --git a/td/telegram/files/FileLocation.hpp b/td/telegram/files/FileLocation.hpp index 8bfad6275..2d6c56342 100644 --- a/td/telegram/files/FileLocation.hpp +++ b/td/telegram/files/FileLocation.hpp @@ -135,7 +135,7 @@ void FullRemoteFileLocation::parse(ParserT &parser) { using ::td::parse; int32 raw_type; parse(raw_type, parser); - web_location_flag_ = (raw_type & WEB_LOCATION_FLAG) != 0; + bool is_web = (raw_type & WEB_LOCATION_FLAG) != 0; raw_type &= ~WEB_LOCATION_FLAG; bool has_file_reference = (raw_type & FILE_REFERENCE_FLAG) != 0; raw_type &= ~FILE_REFERENCE_FLAG; @@ -149,13 +149,17 @@ void FullRemoteFileLocation::parse(ParserT &parser) { if (has_file_reference) { parse(file_reference_, parser); - file_reference_.clear(); + // file_reference_.clear(); + } + if (is_web) { + variant_ = WebRemoteFileLocation(); + return web().parse(parser); } switch (location_type()) { case LocationType::Web: - variant_ = WebRemoteFileLocation(); - return web().parse(parser); + UNREACHABLE(); + break; case LocationType::Photo: variant_ = PhotoRemoteFileLocation(); photo().parse(parser);