You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by jm...@apache.org on 2020/05/06 22:49:28 UTC
[incubator-datasketches-cpp] branch serde_exception updated: avoid
edge case in exception-ready std::string serde rewrite
This is an automated email from the ASF dual-hosted git repository.
jmalkin pushed a commit to branch serde_exception
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-cpp.git
The following commit(s) were added to refs/heads/serde_exception by this push:
new fe6a8cd avoid edge case in exception-ready std::string serde rewrite
fe6a8cd is described below
commit fe6a8cdc3437cb5f74176e58f35d61d1e8469d72
Author: Jon Malkin <jm...@users.noreply.github.com>
AuthorDate: Wed May 6 15:49:14 2020 -0700
avoid edge case in exception-ready std::string serde rewrite
---
common/include/serde.hpp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/common/include/serde.hpp b/common/include/serde.hpp
index 2486bab..fb9aebf 100644
--- a/common/include/serde.hpp
+++ b/common/include/serde.hpp
@@ -118,13 +118,14 @@ struct serde<std::string> {
uint32_t length;
is.read((char*)&length, sizeof(length));
if (!is.good()) { break; }
- new (&items[i]) std::string;
- items[i].reserve(length);
+ std::string str;
+ str.reserve(length);
auto it = std::istreambuf_iterator<char>(is);
for (uint32_t j = 0; j < length; j++) {
- items[i].push_back(*it);
+ str.push_back(*it);
++it;
}
+ new (&items[i]) std::string(std::move(str));
}
} catch (std::istream::failure& e) {
failure = true;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org