From e317d006a0c90fb6cbe2d07f1d1882cb10b1fc96 Mon Sep 17 00:00:00 2001 From: Victor Zarubkin Date: Tue, 27 Sep 2016 01:07:13 +0300 Subject: [PATCH] Linux build without copy --- src/reader.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/reader.cpp b/src/reader.cpp index b86f3a1..6bd7981 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -239,15 +239,15 @@ extern "C" { return 0; ::std::stringstream str; - -#ifdef _WIN32 - str.set_rdbuf(inFile.rdbuf()); -#else - str << inFile.rdbuf(); - inFile.close(); -#endif - return fillTreesFromStream(progress, str, serialized_blocks, serialized_descriptors, descriptors, blocks, threaded_trees, gather_statistics); + typedef ::std::basic_iostream<::std::stringstream::char_type, ::std::stringstream::traits_type> stringstream_parent; + stringstream_parent& s = str; + auto oldbuf = s.rdbuf(inFile.rdbuf()); + + auto result = fillTreesFromStream(progress, str, serialized_blocks, serialized_descriptors, descriptors, blocks, threaded_trees, gather_statistics); + s.rdbuf(oldbuf); + + return result; } //////////////////////////////////////////////////////////////////////////