Skip to content

Commit

Permalink
Refactor from_chars call to use data and size methods
Browse files Browse the repository at this point in the history
Replaced iterators with pointers obtained from data() and size() methods to simplify and potentially improve the efficiency of the from_chars function call. This change is expected to enhance code readability and maintainability.
  • Loading branch information
inakleinbottle committed Nov 4, 2024
1 parent bc23d43 commit eb1829e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion scalars/src/scalar_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ parse_byted_type(string_view id_sub, devices::TypeCode code) noexcept
{
dimn_t bits = 0;

auto result = std::from_chars(&*id_sub.begin(), &*id_sub.end(), bits);
const auto * begin = id_sub.data();
const auto * end = begin + id_sub.size();

auto result = std::from_chars(begin, end, bits);
if (result.ec != std::errc{}) { return {}; }

const auto bytes = static_cast<uint8_t>(bits / CHAR_BIT);
Expand Down

0 comments on commit eb1829e

Please sign in to comment.