Skip to content

Commit 6604385

Browse files
committed
cleanup: avoid needless uninitialized variables.
1 parent e2ad2ee commit 6604385

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

include/highfive/bits/H5Dataspace_misc.hpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,20 @@ inline DataSpace::DataSpace(const std::vector<size_t>& dims, const std::vector<s
7474
}
7575

7676
inline DataSpace::DataSpace(DataSpace::DataspaceType space_type) {
77-
H5S_class_t h5_dataspace_type;
78-
switch (space_type) {
79-
case DataSpace::dataspace_scalar:
80-
h5_dataspace_type = H5S_SCALAR;
81-
break;
82-
case DataSpace::dataspace_null:
83-
h5_dataspace_type = H5S_NULL;
84-
break;
85-
default:
86-
throw DataSpaceException(
87-
"Invalid dataspace type: should be "
88-
"dataspace_scalar or dataspace_null");
89-
}
90-
91-
_hid = detail::h5s_create(h5_dataspace_type);
77+
auto to_hdf5 = [&space_type]() -> H5S_class_t {
78+
switch (space_type) {
79+
case DataSpace::dataspace_scalar:
80+
return H5S_SCALAR;
81+
case DataSpace::dataspace_null:
82+
return H5S_NULL;
83+
default:
84+
throw DataSpaceException(
85+
"Invalid dataspace type: should be "
86+
"dataspace_scalar or dataspace_null");
87+
}
88+
};
89+
90+
_hid = detail::h5s_create(to_hdf5());
9291
}
9392

9493
inline DataSpace DataSpace::clone() const {

0 commit comments

Comments
 (0)