diff --git a/generator/raw_generator.cpp b/generator/raw_generator.cpp index 35cc4387a2..89f9ec6911 100644 --- a/generator/raw_generator.cpp +++ b/generator/raw_generator.cpp @@ -240,24 +240,22 @@ bool RawGenerator::GenerateFilteredFeatures() Stats stats(100 * m_threadsCount /* logCallCountThreshold */); - size_t element_pos = 0; - std::vector elements(m_chunkSize); - while (sourceProcessor->TryRead(elements[element_pos])) + bool isEnd = false; + do { - if (++element_pos != m_chunkSize) - continue; + std::vector elements(m_chunkSize); + size_t idx = 0; + while (idx < m_chunkSize && sourceProcessor->TryRead(elements[idx])) + ++idx; - stats.Log(elements, reader.Pos()); - translators.Emit(elements); + isEnd = idx < m_chunkSize; + stats.Log(elements, reader.Pos(), isEnd/* forcePrint */); - for (auto & e : elements) - e.Clear(); + if (isEnd) + elements.resize(idx); + translators.Emit(std::move(elements)); - element_pos = 0; - } - elements.resize(element_pos); - stats.Log(elements, reader.Pos(), true /* forcePrint */); - translators.Emit(std::move(elements)); + } while (!isEnd); LOG(LINFO, ("Input was processed.")); if (!translators.Finish()) diff --git a/generator/translators_pool.cpp b/generator/translators_pool.cpp index 5cdb0e390a..8c9fcca185 100644 --- a/generator/translators_pool.cpp +++ b/generator/translators_pool.cpp @@ -15,11 +15,12 @@ TranslatorsPool::TranslatorsPool(std::shared_ptr const & or m_translators.Push(original->Clone()); } -void TranslatorsPool::Emit(std::vector elements) +void TranslatorsPool::Emit(std::vector && elements) { std::shared_ptr translator; m_translators.WaitAndPop(translator); - m_threadPool.SubmitWork([&, translator, elements{std::move(elements)}]() mutable { + m_threadPool.SubmitWork([&, translator, elements = std::move(elements)]() mutable + { for (auto & element : elements) translator->Emit(element); diff --git a/generator/translators_pool.hpp b/generator/translators_pool.hpp index d1b907ede0..345164aeef 100644 --- a/generator/translators_pool.hpp +++ b/generator/translators_pool.hpp @@ -18,7 +18,7 @@ public: explicit TranslatorsPool(std::shared_ptr const & original, size_t threadCount); - void Emit(std::vector elements); + void Emit(std::vector && elements); bool Finish(); private: