From: Gabe Black Date: Thu, 2 May 2019 03:16:56 +0000 (-0700) Subject: mem: Use a const T & in write<> to avoid an unnecessary copy. X-Git-Tag: v19.0.0.0~808 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1a631bd79bdcf2d66d845f79758e16e3ec9d7a7f;p=gem5.git 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 Reviewed-by: Jason Lowe-Power Reviewed-by: Andreas Sandberg Maintainer: Andreas Sandberg --- diff --git a/src/mem/port_proxy.hh b/src/mem/port_proxy.hh index 096f82664..469273f85 100644 --- a/src/mem/port_proxy.hh +++ b/src/mem/port_proxy.hh @@ -195,7 +195,7 @@ class PortProxy * Write object T to address. Writes sizeof(T) bytes. */ template - 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 @@ PortProxy::read(Addr address) const template void -PortProxy::write(Addr address, T data) const +PortProxy::write(Addr address, const T &data) const { writeBlob(address, &data, sizeof(T)); }