adamdebreceni commented on a change in pull request #887:
URL: https://github.com/apache/nifi-minifi-cpp/pull/887#discussion_r481940582



##########
File path: libminifi/src/io/DataStream.cpp
##########
@@ -33,7 +33,9 @@ namespace io {
 int DataStream::writeData(uint8_t *value, int size) {
   if (value == nullptr)
     return 0;
-  std::copy(value, value + size, std::back_inserter(buffer));
+  std::size_t previous_size = buffer.size();
+  buffer.resize(previous_size + size);
+  std::memcpy(buffer.data() + previous_size, value, size);

Review comment:
       indeed, I benchmarked `copy` + `back_inserter` and `memcpy` and there is 
a staggering ~20x difference, I figured there would be some template magic 
behind `std::copy` to make use of its arguments' types, but seems like that is 
not the case




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to