From f3ef0779b5c7dafdc05919b2cbf850c649c1e702 Mon Sep 17 00:00:00 2001 From: Philipp Moritz Date: Tue, 5 Feb 2019 17:09:29 -0800 Subject: [PATCH 1/2] use stringstreams instead of std::to_string and std::stoi --- cpp/src/arrow/python/deserialize.cc | 7 +++++-- cpp/src/arrow/python/serialize.cc | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cpp/src/arrow/python/deserialize.cc b/cpp/src/arrow/python/deserialize.cc index f13070a5883..13fc73c70a8 100644 --- a/cpp/src/arrow/python/deserialize.cc +++ b/cpp/src/arrow/python/deserialize.cc @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -195,8 +196,10 @@ std::vector GetPythonTypes(const UnionArray& data) { std::vector result; auto type = data.type(); for (int i = 0; i < type->num_children(); ++i) { - // stoi is locale dependent, but should be ok for small integers - result.push_back(static_cast(std::stoi(type->child(i)->name()))); + std::istringstream convert(type->child(i)->name()); + int8_t tag; + convert >> tag; + result.push_back(tag); } return result; } diff --git a/cpp/src/arrow/python/serialize.cc b/cpp/src/arrow/python/serialize.cc index 3ccdfc8eee5..17f3dba4cff 100644 --- a/cpp/src/arrow/python/serialize.cc +++ b/cpp/src/arrow/python/serialize.cc @@ -90,8 +90,9 @@ class SequenceBuilder { MakeBuilderFn make_builder) { if (!*child_builder) { child_builder->reset(make_builder()); - // std::to_string is locale dependent, but should be ok for small integers - type_map_[tag] = builder_->AppendChild(*child_builder, std::to_string(tag)); + std::ostringstream convert; + convert << tag; + type_map_[tag] = builder_->AppendChild(*child_builder, convert.str()); } return Update(child_builder->get(), type_map_[tag]); } From 7c8b81da169d10eece377944618217d198adc05e Mon Sep 17 00:00:00 2001 From: Philipp Moritz Date: Tue, 5 Feb 2019 20:44:14 -0800 Subject: [PATCH 2/2] update --- cpp/src/arrow/python/deserialize.cc | 6 +++--- cpp/src/arrow/python/serialize.cc | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cpp/src/arrow/python/deserialize.cc b/cpp/src/arrow/python/deserialize.cc index 13fc73c70a8..979399646ad 100644 --- a/cpp/src/arrow/python/deserialize.cc +++ b/cpp/src/arrow/python/deserialize.cc @@ -21,8 +21,8 @@ #include #include -#include #include +#include #include #include @@ -197,9 +197,9 @@ std::vector GetPythonTypes(const UnionArray& data) { auto type = data.type(); for (int i = 0; i < type->num_children(); ++i) { std::istringstream convert(type->child(i)->name()); - int8_t tag; + int tag; convert >> tag; - result.push_back(tag); + result.push_back(static_cast(tag)); } return result; } diff --git a/cpp/src/arrow/python/serialize.cc b/cpp/src/arrow/python/serialize.cc index 17f3dba4cff..4d5b02984cf 100644 --- a/cpp/src/arrow/python/serialize.cc +++ b/cpp/src/arrow/python/serialize.cc @@ -91,7 +91,7 @@ class SequenceBuilder { if (!*child_builder) { child_builder->reset(make_builder()); std::ostringstream convert; - convert << tag; + convert << static_cast(tag); type_map_[tag] = builder_->AppendChild(*child_builder, convert.str()); } return Update(child_builder->get(), type_map_[tag]);