From 5e39f8a55c127815580131d91e76fd81998152fa Mon Sep 17 00:00:00 2001 From: LaGrunge Date: Fri, 16 Aug 2019 15:14:17 +0300 Subject: [PATCH] [coding] FileContainer::Write(void const *, size_t, Tag) --- coding/file_container.cpp | 12 ++++++++---- coding/file_container.hpp | 1 + indexer/locality_index_builder.cpp | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/coding/file_container.cpp b/coding/file_container.cpp index ac2e764a28..fe40e70173 100644 --- a/coding/file_container.cpp +++ b/coding/file_container.cpp @@ -448,16 +448,20 @@ void FilesContainerW::Write(ModelReaderPtr reader, Tag const & tag) rw::ReadAndWrite(src, *writer); } +void FilesContainerW::Write(void const * buffer, size_t size, Tag const & tag) +{ + if (size != 0) + GetWriter(tag)->Write(buffer, size); +} + void FilesContainerW::Write(vector const & buffer, Tag const & tag) { - if (!buffer.empty()) - GetWriter(tag)->Write(buffer.data(), buffer.size()); + Write(buffer.data(), buffer.size(), tag); } void FilesContainerW::Write(vector const & buffer, Tag const & tag) { - if (!buffer.empty()) - GetWriter(tag)->Write(buffer.data(), buffer.size()); + Write(buffer.data(), buffer.size(), tag); } void FilesContainerW::Finish() diff --git a/coding/file_container.hpp b/coding/file_container.hpp index ce2a61823e..b72388a220 100644 --- a/coding/file_container.hpp +++ b/coding/file_container.hpp @@ -245,6 +245,7 @@ public: void Write(std::string const & fPath, Tag const & tag); void Write(ModelReaderPtr reader, Tag const & tag); + void Write(void const * buffer, size_t size, Tag const & tag); void Write(std::vector const & buffer, Tag const & tag); void Write(std::vector const & buffer, Tag const & tag); diff --git a/indexer/locality_index_builder.cpp b/indexer/locality_index_builder.cpp index d7856d444e..4108d5e663 100644 --- a/indexer/locality_index_builder.cpp +++ b/indexer/locality_index_builder.cpp @@ -79,7 +79,7 @@ bool BuildLocalityIndexFromDataFile(string const & dataFile, FilesContainerW writer(outFileName, FileWriter::OP_WRITE_TRUNCATE); writer.Write(idxFileName, localityIndexFileTag); - writer.Write(std::vector(dataVersionJson.begin(), dataVersionJson.end()), dataVersionTag); + writer.Write(dataVersionJson.c_str(), dataVersionJson.size(), dataVersionTag); FileWriter::DeleteFileX(idxFileName); } catch (Reader::Exception const & e)