Skip to content

Commit 02478a6

Browse files
committed
Use a function rather than a macro
1 parent e6d3d88 commit 02478a6

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

cpp/src/arrow/ipc/metadata_internal.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ struct FileBlock {
9696
" in flatbuffer-encoded metadata"); \
9797
}
9898

99-
#define FLATBUFFERS_VECTOR_SIZE(fb_vector) \
100-
((fb_vector == NULLPTR) ? 0 : fb_vector->size())
99+
template <typename T>
100+
inline uint32_t FlatBuffersVectorSize(const flatbuffers::Vector<T>* vec) {
101+
return (vec == NULLPTR) ? 0 : vec->size();
102+
}
101103

102104
inline std::string StringFromFlatbuffers(const flatbuffers::String* s) {
103105
return (s == NULLPTR) ? "" : s->str();

cpp/src/arrow/ipc/reader.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,11 +657,11 @@ class RecordBatchFileReader::RecordBatchFileReaderImpl {
657657
}
658658

659659
int num_dictionaries() const {
660-
return FLATBUFFERS_VECTOR_SIZE(footer_->dictionaries());
660+
return static_cast<int>(internal::FlatBuffersVectorSize(footer_->dictionaries()));
661661
}
662662

663663
int num_record_batches() const {
664-
return FLATBUFFERS_VECTOR_SIZE(footer_->recordBatches());
664+
return static_cast<int>(internal::FlatBuffersVectorSize(footer_->recordBatches()));
665665
}
666666

667667
MetadataVersion version() const {

0 commit comments

Comments
 (0)