[memprof] Avoid meaningless pod copy
authorWu, Yingcong <yingcong.wu@intel.com>
Thu, 2 Mar 2023 01:36:37 +0000 (01:36 +0000)
committerSnehasish Kumar <snehasishk@google.com>
Thu, 2 Mar 2023 01:39:01 +0000 (01:39 +0000)
The pointer `Buffer` is not changed, so there is no need to use reference, and the `Pod` here should use reference to avoid meaningless copy.

Reviewed By: snehasish

Differential Revision: https://reviews.llvm.org/D145024

compiler-rt/lib/memprof/memprof_rawprofile.cpp

index f065e8d..88f3c34 100644 (file)
@@ -20,7 +20,7 @@ using SegmentEntry = ::llvm::memprof::SegmentEntry;
 using Header = ::llvm::memprof::Header;
 
 namespace {
-template <class T> char *WriteBytes(T Pod, char *&Buffer) {
+template <class T> char *WriteBytes(const T &Pod, char *Buffer) {
   *(T *)Buffer = Pod;
   return Buffer + sizeof(T);
 }