3636
3737namespace arrow {
3838
39- static inline bool BufferBuilderCapacityTooLarge (int64_t capacity) {
40- return ARROW_PREDICT_FALSE (capacity > std::numeric_limits<int64_t >::max () - 63 );
41- }
42-
4339// ----------------------------------------------------------------------
4440// Buffer builder classes
4541
@@ -79,12 +75,6 @@ class ARROW_EXPORT BufferBuilder {
7975 // / shrinking the builder.
8076 // / \return Status
8177 Status Resize (const int64_t new_capacity, bool shrink_to_fit = true ) {
82- if (ARROW_PREDICT_FALSE (new_capacity < 0 )) {
83- return Status::Invalid (" Resize: negative capacity" );
84- }
85- if (ARROW_PREDICT_FALSE (BufferBuilderCapacityTooLarge (new_capacity))) {
86- return Status::CapacityError (" Resize: capacity overflow" );
87- }
8878 if (buffer_ == NULLPTR ) {
8979 ARROW_ASSIGN_OR_RAISE (buffer_,
9080 AllocateResizableBuffer (new_capacity, alignment_, pool_));
@@ -110,16 +100,10 @@ class ARROW_EXPORT BufferBuilder {
110100 internal::AddWithOverflow (size_, additional_bytes, &min_capacity))) {
111101 return Status::CapacityError (" Reserve: capacity overflow" );
112102 }
113- if (ARROW_PREDICT_FALSE (BufferBuilderCapacityTooLarge (min_capacity))) {
114- return Status::CapacityError (" Reserve: capacity overflow" );
115- }
116103 if (min_capacity <= capacity_) {
117104 return Status::OK ();
118105 }
119106 int64_t requested_capacity = GrowByFactor (capacity_, min_capacity);
120- if (ARROW_PREDICT_FALSE (BufferBuilderCapacityTooLarge (requested_capacity))) {
121- return Status::CapacityError (" Reserve: capacity overflow" );
122- }
123107 return Resize (requested_capacity, false );
124108 }
125109
@@ -342,9 +326,6 @@ class TypedBufferBuilder<
342326 new_capacity, static_cast <int64_t >(sizeof (T)), &num_bytes))) {
343327 return Status::CapacityError (" Resize: capacity overflow" );
344328 }
345- if (ARROW_PREDICT_FALSE (BufferBuilderCapacityTooLarge (num_bytes))) {
346- return Status::CapacityError (" Resize: capacity overflow" );
347- }
348329 return bytes_builder_.Resize (num_bytes, shrink_to_fit);
349330 }
350331
@@ -357,9 +338,6 @@ class TypedBufferBuilder<
357338 additional_elements, static_cast <int64_t >(sizeof (T)), &num_bytes))) {
358339 return Status::CapacityError (" Reserve: size overflow" );
359340 }
360- if (ARROW_PREDICT_FALSE (BufferBuilderCapacityTooLarge (num_bytes))) {
361- return Status::CapacityError (" Reserve: size overflow" );
362- }
363341 return bytes_builder_.Reserve (num_bytes);
364342 }
365343
@@ -525,9 +503,6 @@ class TypedBufferBuilder<bool> {
525503 internal::AddWithOverflow (bit_length_, additional_elements, &min_length))) {
526504 return Status::CapacityError (" Reserve: capacity overflow" );
527505 }
528- if (ARROW_PREDICT_FALSE (BufferBuilderCapacityTooLarge (min_length))) {
529- return Status::CapacityError (" Reserve: capacity overflow" );
530- }
531506 return Resize (min_length, false );
532507 }
533508
0 commit comments