You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by al...@apache.org on 2020/07/06 23:10:37 UTC

[incubator-datasketches-cpp] 01/01: simplify and avoid iterating past the end

This is an automated email from the ASF dual-hosted git repository.

alsay pushed a commit to branch msvc_compatibility
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-cpp.git

commit 0ad62127fdf636104365cde4feb87f8726760b3a
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Mon Jul 6 16:10:23 2020 -0700

    simplify and avoid iterating past the end
---
 common/include/serde.hpp | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/common/include/serde.hpp b/common/include/serde.hpp
index d610adb..74de784 100644
--- a/common/include/serde.hpp
+++ b/common/include/serde.hpp
@@ -114,17 +114,16 @@ struct serde<std::string> {
     unsigned i = 0;
     bool failure = false;
     try {
-      for (; i < num && is.good(); i++) {
+      for (; i < num; i++) {
         uint32_t length;
         is.read((char*)&length, sizeof(length));
         if (!is.good()) { break; }
         std::string str;
         str.reserve(length);
-        auto it = std::istreambuf_iterator<char>(is);
         for (uint32_t j = 0; j < length; j++) {
-          str.push_back(*it);
-          ++it;
+          str.push_back(is.get());
         }
+        if (!is.good()) { break; }
         new (&items[i]) std::string(std::move(str));
       }
     } catch (std::istream::failure& e) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org