From 2166b6faf607d5283bf91b406bc499ac5fe911c2 Mon Sep 17 00:00:00 2001 From: Maxim Pimenov Date: Wed, 23 Sep 2015 14:25:31 +0300 Subject: [PATCH] [omim] Fix compilation of is_trivially_copyable in DDVector. --- generator/feature_sorter.cpp | 12 +++++++++--- indexer/feature_loader.cpp | 38 ++++++++++++++++++++++++------------ 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/generator/feature_sorter.cpp b/generator/feature_sorter.cpp index f906c21255..2ff3f7f039 100644 --- a/generator/feature_sorter.cpp +++ b/generator/feature_sorter.cpp @@ -21,8 +21,9 @@ #include "coding/file_container.hpp" #include "coding/file_name_utils.hpp" -#include "base/string_utils.hpp" +#include "base/assert.hpp" #include "base/logging.hpp" +#include "base/string_utils.hpp" namespace { @@ -91,8 +92,12 @@ namespace feature unique_ptr m_MetadataWriter; - struct MetadataIndexValueT { uint32_t key, value; }; - vector m_MetadataIndex; + struct TMetadataIndexEntry + { + uint32_t key; + uint32_t value; + }; + vector m_MetadataIndex; DataHeader m_header; uint32_t m_versionDate; @@ -504,6 +509,7 @@ namespace feature if (!fb.GetMetadata().Empty()) { uint64_t offset = m_MetadataWriter->Pos(); + ASSERT_LESS_OR_EQUAL(offset, numeric_limits::max(), ()); m_MetadataIndex.push_back({ ftID, static_cast(offset) }); fb.GetMetadata().SerializeToMWM(*m_MetadataWriter); } diff --git a/indexer/feature_loader.cpp b/indexer/feature_loader.cpp index 0e79af92bd..23c69645a1 100644 --- a/indexer/feature_loader.cpp +++ b/indexer/feature_loader.cpp @@ -1,17 +1,22 @@ #include "base/SRC_FIRST.hpp" -#include "indexer/feature_loader.hpp" -#include "indexer/feature.hpp" -#include "indexer/scales.hpp" -#include "indexer/geometry_serialization.hpp" #include "indexer/classificator.hpp" +#include "indexer/feature.hpp" +#include "indexer/feature_loader.hpp" +#include "indexer/geometry_serialization.hpp" +#include "indexer/scales.hpp" #include "geometry/pointu_to_uint64.hpp" #include "coding/byte_stream.hpp" #include "coding/dd_vector.hpp" +#include "base/assert.hpp" #include "base/logging.hpp" + +#include "std/algorithm.hpp" +#include "std/limits.hpp" + #include "defines.hpp" namespace feature @@ -256,18 +261,25 @@ void LoaderCurrent::ParseMetadata() { try { - typedef pair IdxElementT; - DDVector idx(m_Info.GetMetadataIndexReader()); - - auto it = lower_bound(idx.begin(), idx.end() - , make_pair(uint32_t(m_pF->m_id.m_index), uint32_t(0)) - , [](IdxElementT const & v1, IdxElementT const & v2) { return v1.first < v2.first; } - ); + struct TMetadataIndexEntry + { + uint32_t key; + uint32_t value; + }; + DDVector idx(m_Info.GetMetadataIndexReader()); - if (it != idx.end() && m_pF->m_id.m_index == it->first) + auto it = lower_bound( + idx.begin(), idx.end(), + TMetadataIndexEntry{static_cast(m_pF->m_id.m_index), 0}, + [](TMetadataIndexEntry const & v1, TMetadataIndexEntry const & v2) + { + return v1.key < v2.key; + }); + + if (it != idx.end() && m_pF->m_id.m_index == it->key) { ReaderSource reader(m_Info.GetMetadataReader()); - reader.Skip(it->second); + reader.Skip(it->value); m_pF->GetMetadata().DeserializeFromMWM(reader); } }