[generator] Added call Clear().

This commit is contained in:
Maksim Andrianov 2020-12-08 14:26:07 +03:00 committed by mpimenov
parent 0df8e92640
commit d903219a8a
4 changed files with 13 additions and 6 deletions

View file

@ -123,7 +123,10 @@ void ProcessOsmElementsFromXML(SourceReader & stream, function<void(OsmElement *
ProcessorOsmElementsFromXml processorOsmElementsFromXml(stream);
OsmElement element;
while (processorOsmElementsFromXml.TryRead(element))
{
processor(&element);
element.Clear();
}
}
void BuildIntermediateDataFromO5M(SourceReader & stream, cache::IntermediateDataWriter & cache,
@ -144,7 +147,10 @@ void ProcessOsmElementsFromO5M(SourceReader & stream, function<void(OsmElement *
ProcessorOsmElementsFromO5M processorOsmElementsFromO5M(stream);
OsmElement element;
while (processorOsmElementsFromO5M.TryRead(element))
{
processor(&element);
element.Clear();
}
}
ProcessorOsmElementsFromO5M::ProcessorOsmElementsFromO5M(SourceReader & stream)
@ -172,8 +178,6 @@ bool ProcessorOsmElementsFromO5M::TryRead(OsmElement & element)
}
};
element = {};
// Be careful, we could call Nodes(), Members(), Tags() from O5MSource::Entity
// only once (!). Because these functions read data from file simultaneously with
// iterating in loop. Furthermore, into Tags() method calls Nodes.Skip() and Members.Skip(),

View file

@ -183,8 +183,11 @@ bool RawGenerator::GenerateFilteredFeatures()
if (++element_pos != m_chunkSize)
continue;
translators.Emit(std::move(elements));
elements = std::vector<OsmElement>(m_chunkSize);
translators.Emit(elements);
for (auto & e : elements)
e.Clear();
element_pos = 0;
}
elements.resize(element_pos);

View file

@ -15,7 +15,7 @@ TranslatorsPool::TranslatorsPool(std::shared_ptr<TranslatorInterface> const & or
m_translators.Push(original->Clone());
}
void TranslatorsPool::Emit(std::vector<OsmElement> && elements)
void TranslatorsPool::Emit(std::vector<OsmElement> elements)
{
std::shared_ptr<TranslatorInterface> translator;
m_translators.WaitAndPop(translator);

View file

@ -18,7 +18,7 @@ public:
explicit TranslatorsPool(std::shared_ptr<TranslatorInterface> const & original,
size_t threadCount);
void Emit(std::vector<OsmElement> && elements);
void Emit(std::vector<OsmElement> elements);
bool Finish();
private: