Skip to content

Commit

Permalink
Tweak ToEndian methods
Browse files Browse the repository at this point in the history
  • Loading branch information
benibus committed Nov 14, 2023
1 parent 157e0d7 commit 5eb90d7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cpp/src/arrow/util/float16.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ class ARROW_EXPORT Float16 {

/// \brief Copy the value's bytes in little-endian byte order
void ToLittleEndian(uint8_t* dest) const {
FromBits(::arrow::bit_util::ToLittleEndian(bits_)).ToBytes(dest);
const auto bytes = ToLittleEndian();
std::memcpy(dest, bytes.data(), bytes.size());
}
/// \brief Return the value's bytes in little-endian byte order
constexpr std::array<uint8_t, 2> ToLittleEndian() const {
Expand All @@ -119,7 +120,8 @@ class ARROW_EXPORT Float16 {

/// \brief Copy the value's bytes in big-endian byte order
void ToBigEndian(uint8_t* dest) const {
FromBits(::arrow::bit_util::ToBigEndian(bits_)).ToBytes(dest);
const auto bytes = ToBigEndian();
std::memcpy(dest, bytes.data(), bytes.size());
}
/// \brief Return the value's bytes in big-endian byte order
constexpr std::array<uint8_t, 2> ToBigEndian() const {
Expand Down

0 comments on commit 5eb90d7

Please sign in to comment.