Skip to content

Commit c1f393f

Browse files
committed
- Reimplemented BytesToString more efficiently.
- Updated comments on Int96 struct.
1 parent e0c093b commit c1f393f

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

src/common/bytes_utils.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -403,10 +403,5 @@ inline std::vector<uint8_t> StringToBytes(const std::string& str) {
403403
}
404404

405405
inline std::string BytesToString(tcb::span<const uint8_t> span) {
406-
std::string result;
407-
result.reserve(span.size());
408-
for (const uint8_t byte : span) {
409-
result += static_cast<char>(byte);
410-
}
411-
return result;
406+
return std::string(reinterpret_cast<const char*>(span.data()), span.size());
412407
}

src/processing/typed_buffer_codecs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
namespace dbps::processing {
2929

30+
// The values in Int96 of low/mid/hi are stored in little endian order.
31+
// The order of low/mid/hi in the C++ struct should be kept, otherwise the codec will yield incorrect values.
3032
struct Int96 {
3133
int32_t lo;
3234
int32_t mid;

0 commit comments

Comments
 (0)