From 502a84c30ddf98732eb76ae08222371a75fc01fd Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Thu, 7 Jul 2022 08:00:15 +0200 Subject: [PATCH] Update src/awkward/_v2/cpp-headers/GrowableBuffer.h fix compilation errors on Mac --- src/awkward/_v2/cpp-headers/GrowableBuffer.h | 25 ++++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/awkward/_v2/cpp-headers/GrowableBuffer.h b/src/awkward/_v2/cpp-headers/GrowableBuffer.h index cb229488d7..852a20cc78 100644 --- a/src/awkward/_v2/cpp-headers/GrowableBuffer.h +++ b/src/awkward/_v2/cpp-headers/GrowableBuffer.h @@ -238,27 +238,26 @@ namespace awkward { return (ptr_.size() == 1); } - /// @brief Takes one (possibly multi-panels) GrowableBuffer + /// @brief Takes this (possibly multi-panels) GrowableBuffer /// and makes another (one panel) GrowableBuffer. /// - /// Used to change the data type of buffer content from `FROM_PRIMITIVE` + /// Used to change the data type of buffer content from `PRIMITIVE` /// to `TO_PRIMITIVE` for building arrays. - template - static GrowableBuffer - fill_from(GrowableBuffer& from_buffer) { - auto length = from_buffer.length(); - auto ptr = std::unique_ptr(new PRIMITIVE[length]); - PRIMITIVE* rawptr = ptr.get(); + template + GrowableBuffer + copy_as() { + auto len = length(); + auto ptr = std::unique_ptr(new TO_PRIMITIVE[len]); + TO_PRIMITIVE* rawptr = ptr.get(); int64_t k = 0; - for (size_t i = 0; i < from_buffer.ptr_.size(); i++) { - for (int64_t j = 0; j < from_buffer.length_[i]; j++) { - rawptr[k] = static_cast(from_buffer.ptr_[i].get()[j]); + for (size_t i = 0; i < ptr_.size(); i++) { + for (int64_t j = 0; j < length_[i]; j++) { + rawptr[k] = static_cast(ptr_[i].get()[j]); k++; } } - return GrowableBuffer(length, std::move(ptr), length, length); + return GrowableBuffer(len, std::move(ptr), len, len); } - private: /// @brief Inserts one `datum` into the panel. void