apilloud commented on code in PR #3740:
URL: https://github.com/apache/avro/pull/3740#discussion_r3133620860
##########
lang/c++/include/avro/buffer/detail/BufferDetail.hh:
##########
@@ -320,7 +320,7 @@ public:
if (freeSpace_ && (sizeof(T) <= writeChunks_.front().freeSize())) {
// fast path, there's enough room in the writeable chunk to just
// straight out copy it
- *(reinterpret_cast<T *>(writeChunks_.front().tellWritePos())) =
val;
+ memcpy(writeChunks_.front().tellWritePos(), &val, sizeof(T));
Review Comment:
This file already uses memcpy, rather than std::memcpy. I don't know of a
reason to prefer std::memcpy over memcpy, so I'm going to stick with that.
It doesn't appear to be necessary, and memcpy is already used here, but I
can add `#include <cstring>` if you'd like.
##########
lang/c++/include/avro/buffer/detail/BufferDetail.hh:
##########
@@ -320,7 +320,7 @@ public:
if (freeSpace_ && (sizeof(T) <= writeChunks_.front().freeSize())) {
// fast path, there's enough room in the writeable chunk to just
// straight out copy it
- *(reinterpret_cast<T *>(writeChunks_.front().tellWritePos())) =
val;
+ memcpy(writeChunks_.front().tellWritePos(), &val, sizeof(T));
postWrite(sizeof(T));
} else {
// need to fixup chunks first, so use the regular memcpy
Review Comment:
The actual implementation of writeTo is a memcpy:
https://github.com/apache/avro/pull/3740/changes/BASE..14aa89a4aded2b202e6402a6c277d40ed7cfd5b2#diff-e480d7690c296659bf5547ee3c64047c8902d7f9343c55f404b985b383d3ae66R351
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]