98
98
#include < type_traits>
99
99
#include < utility>
100
100
101
+ #include " absl/base/optimization.h"
102
+
101
103
#if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)
102
104
// If MSVC has "/RTCc" set, it will complain about truncating casts at
103
105
// runtime. This file contains some intentional truncating casts.
@@ -821,6 +823,29 @@ class PROTOBUF_EXPORT EpsCopyOutputStream {
821
823
int64_t ByteCount (uint8_t * ptr) const ;
822
824
823
825
826
+ #ifdef PROTOBUF_INTERNAL_V2_EXPERIMENT
827
+ template <typename ValT, typename CallbackT>
828
+ uint8_t * WriteNumericArray (uint8_t * ptr, uint32_t count,
829
+ CallbackT&& callback) {
830
+ static_assert (sizeof (ValT) > 1 , " Use WriteRaw" );
831
+ static_assert (sizeof (ValT) < kSlopBytes , " " );
832
+
833
+ int64_t size = count * sizeof (ValT);
834
+ while (size > 0 ) {
835
+ ptr = EnsureSpace (ptr);
836
+ int64_t chunk_size = std::min<int64_t >(GetSize (ptr), size);
837
+ int64_t round_down_size = (chunk_size / sizeof (ValT)) * sizeof (ValT);
838
+ ABSL_DCHECK_GT (round_down_size, 0u );
839
+
840
+ callback (ptr, round_down_size);
841
+
842
+ size -= round_down_size;
843
+ ptr += round_down_size;
844
+ }
845
+ return ptr;
846
+ }
847
+ #endif // PROTOBUF_INTERNAL_V2_EXPERIMENT
848
+
824
849
private:
825
850
uint8_t * end_;
826
851
uint8_t * buffer_end_ = buffer_;
@@ -829,7 +854,7 @@ class PROTOBUF_EXPORT EpsCopyOutputStream {
829
854
bool had_error_ = false ;
830
855
bool aliasing_enabled_ = false ; // See EnableAliasing().
831
856
bool is_serialization_deterministic_;
832
- bool skip_check_consistency = false ;
857
+ bool skip_check_consistency_ = false ;
833
858
834
859
uint8_t * EnsureSpaceFallback (uint8_t * ptr);
835
860
inline uint8_t * Next ();
0 commit comments