Minor search::Metadata processing optimization.

This commit is contained in:
Alex Zolotarev 2016-02-11 17:23:11 +03:00 committed by Sergey Yershov
parent 35d40cd8fb
commit a046daa073
2 changed files with 5 additions and 1 deletions

View file

@ -1178,7 +1178,7 @@ void Framework::LoadSearchResultMetadata(search::Result & res) const
FeatureID const & id = res.GetFeatureID();
if (id.IsValid())
search::ProcessMetadata(*GetFeatureByID(id), res.m_metadata);
res.m_metadata.m_isInitialized = true;
// res.m_metadata.m_isInitialized is set to true in ProcessMetadata.
}
void Framework::ShowSearchResult(search::Result const & res)

View file

@ -28,6 +28,9 @@ double const DIST_SAME_STREET = 5000.0;
void ProcessMetadata(FeatureType const & ft, Result::Metadata & meta)
{
if (meta.m_isInitialized)
return;
feature::Metadata const & src = ft.GetMetadata();
meta.m_cuisine = src.Get(feature::Metadata::FMD_CUISINE);
@ -47,6 +50,7 @@ void ProcessMetadata(FeatureType const & ft, Result::Metadata & meta)
meta.m_stars = my::clamp(meta.m_stars, 0, 5);
else
meta.m_stars = 0;
meta.m_isInitialized = true;
}
namespace impl