Gabe Black has submitted this change and it was merged. ( https://gem5-review.googlesource.com/c/public/gem5/+/18573 )

Change subject: mem: Use a const T & in write<> to avoid an unnecessary copy.
......................................................................

mem: Use a const T & in write<> to avoid an unnecessary copy.

If the type T is complex/large, the it makes sense to access it in place
and not copy it and then not modify it.

Change-Id: Idd24be4fbba636375637ff72b1ba5ee32eb76215
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18573
Tested-by: kokoro <[email protected]>
Reviewed-by: Jason Lowe-Power <[email protected]>
Reviewed-by: Andreas Sandberg <[email protected]>
Maintainer: Andreas Sandberg <[email protected]>
---
M src/mem/port_proxy.hh
1 file changed, 2 insertions(+), 2 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved
  Andreas Sandberg: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/mem/port_proxy.hh b/src/mem/port_proxy.hh
index 096f826..469273f 100644
--- a/src/mem/port_proxy.hh
+++ b/src/mem/port_proxy.hh
@@ -195,7 +195,7 @@
      * Write object T to address. Writes sizeof(T) bytes.
      */
     template <typename T>
-    void write(Addr address, T data) const;
+    void write(Addr address, const T &data) const;

     /**
      * Read sizeof(T) bytes from address and return as object T.
@@ -256,7 +256,7 @@

 template <typename T>
 void
-PortProxy::write(Addr address, T data) const
+PortProxy::write(Addr address, const T &data) const
 {
     writeBlob(address, &data, sizeof(T));
 }

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/18573
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Idd24be4fbba636375637ff72b1ba5ee32eb76215
Gerrit-Change-Number: 18573
Gerrit-PatchSet: 5
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Nikos Nikoleris <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to