Skip to content

Commit b419a90

Browse files
committed
use switch_case instead of if
1 parent 1d05bfb commit b419a90

1 file changed

Lines changed: 9 additions & 15 deletions

File tree

cpp/src/arrow/array/builder_base.h

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,22 +117,16 @@ class ARROW_EXPORT ArrayBuilder {
117117
/// \brief Return true if value at index is valid (not null). Does not
118118
/// boundscheck.
119119
/// Note that this method does not work for types that do not have a
120-
/// top-level validity bitmap ( Union and Run-End Encoded (RLE) types).
120+
/// top-level validity bitmap (Union and Run-End Encoded (RLE) types).
121121
bool IsValid(int64_t i) const {
122-
if (type()->id() == Type::NA) {
123-
return false;
124-
} else if (type()->id() == Type::SPARSE_UNION) {
125-
// Not implemented
126-
return false;
127-
} else if (type()->id() == Type::DENSE_UNION) {
128-
// Not implemented
129-
return false;
130-
} else if (type()->id() == Type::RUN_END_ENCODED) {
131-
// Not implemented
132-
return false;
133-
} else {
134-
// NullType
135-
return bit_util::GetBit(null_bitmap_builder_.data(), i);
122+
switch (type()->id()) {
123+
case Type::NA:
124+
case Type::SPARSE_UNION:
125+
case Type::DENSE_UNION:
126+
case Type::RUN_END_ENCODED:
127+
return false;
128+
default:
129+
return bit_util::GetBit(null_bitmap_builder_.data(), i);
136130
}
137131
}
138132

0 commit comments

Comments
 (0)