mirror of
https://github.com/KingDuckZ/incredis
synced 2024-11-27 00:43:50 +00:00
Don't copy nul-terminators if any.
This commit is contained in:
parent
dc3f817db5
commit
a8a27b307f
1 changed files with 4 additions and 2 deletions
|
@ -66,13 +66,15 @@ namespace redis {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct IntConv<T, std::enable_if_t<std::is_integral_v<T>, std::string>> {
|
struct IntConv<T, std::enable_if_t<std::is_integral_v<T>, std::string>> {
|
||||||
static T conv (const std::string& in) {
|
static T conv (const std::string& in) {
|
||||||
return dhandy::ary_to_int<T, char, 10, AsciiTranslator>(in.data(), in.data() + in.size());
|
const auto size = in.size() - (in.empty() or in.back() ? 0 : 1);
|
||||||
|
return dhandy::ary_to_int<T, char, 10, AsciiTranslator>(in.data(), in.data() + size);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct IntConv<T, std::enable_if_t<std::is_integral_v<T>, boost::string_view>> {
|
struct IntConv<T, std::enable_if_t<std::is_integral_v<T>, boost::string_view>> {
|
||||||
static T conv (const boost::string_view& in) {
|
static T conv (const boost::string_view& in) {
|
||||||
return dhandy::ary_to_int<T, char, 10, AsciiTranslator>(in.data(), in.data() + in.size());
|
const auto size = in.size() - (in.empty() or in.back() ? 0 : 1);
|
||||||
|
return dhandy::ary_to_int<T, char, 10, AsciiTranslator>(in.data(), in.data() + size);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} //namespace implem
|
} //namespace implem
|
||||||
|
|
Loading…
Reference in a new issue