Skip to content

Commit

Permalink
Use a function rather than a macro
Browse files Browse the repository at this point in the history
  • Loading branch information
pitrou committed Feb 4, 2020
1 parent e6d3d88 commit 02478a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions cpp/src/arrow/ipc/metadata_internal.h
Expand Up @@ -96,8 +96,10 @@ struct FileBlock {
" in flatbuffer-encoded metadata"); \
}

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

inline std::string StringFromFlatbuffers(const flatbuffers::String* s) {
return (s == NULLPTR) ? "" : s->str();
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/ipc/reader.cc
Expand Up @@ -657,11 +657,11 @@ class RecordBatchFileReader::RecordBatchFileReaderImpl {
}

int num_dictionaries() const {
return FLATBUFFERS_VECTOR_SIZE(footer_->dictionaries());
return static_cast<int>(internal::FlatBuffersVectorSize(footer_->dictionaries()));
}

int num_record_batches() const {
return FLATBUFFERS_VECTOR_SIZE(footer_->recordBatches());
return static_cast<int>(internal::FlatBuffersVectorSize(footer_->recordBatches()));
}

MetadataVersion version() const {
Expand Down

0 comments on commit 02478a6

Please sign in to comment.