Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions include/highfive/bits/H5Attribute_misc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ inline T Attribute::read() const {
template <typename T>
inline void Attribute::read(T& array) const {
const DataSpace& mem_space = getMemSpace();
auto dims = mem_space.getDimensions();

if (mem_space.getElementCount() == 0) {
details::inspector<T>::prepare(array, dims);
return;
}

auto file_datatype = getDataType();
const details::BufferInfo<T> buffer_info(
file_datatype,
Expand All @@ -81,12 +88,6 @@ inline void Attribute::read(T& array) const {
<< buffer_info.getMaxRank() << "(max)";
throw DataSpaceException(ss.str());
}
auto dims = mem_space.getDimensions();

if (mem_space.getElementCount() == 0) {
details::inspector<T>::prepare(array, dims);
return;
}

auto r = details::data_converter::get_reader<T>(dims, array, file_datatype);
read_raw(r.getPointer(), buffer_info.data_type);
Expand Down Expand Up @@ -133,7 +134,6 @@ inline void Attribute::write(const T& buffer) {
}

auto file_datatype = getDataType();

const details::BufferInfo<T> buffer_info(
file_datatype,
[this]() -> std::string { return this->getName(); },
Expand Down
Loading