From: Marek Vasut Date: Tue, 28 May 2019 04:44:52 +0200 Subject: [U-Boot] [PATCH 1/3] spl: ram: Do not memcpy() identical buffers In-Reply-To: <20190528024213.GK20781@bill-the-cat> References: <20190528014915.6202-1-marex@denx.de> <20190528020600.GJ20781@bill-the-cat> <20190528024213.GK20781@bill-the-cat> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 5/28/19 4:42 AM, Tom Rini wrote: > On Tue, May 28, 2019 at 04:07:44AM +0200, Marek Vasut wrote: >> On 5/28/19 4:06 AM, Tom Rini wrote: >>> On Tue, May 28, 2019 at 03:49:13AM +0200, Marek Vasut wrote: >>> >>>> If the source and destination buffer address is identical, there is >>>> no need to memcpy() the content. Skip the memcpy() in such a case. >>>> >>>> Signed-off-by: Marek Vasut >>>> Cc: Michal Simek >>>> Cc: Tom Rini >>> >>> Shouldn't memcpy catch that itself? >>> >> memcpy(3) says >> The memcpy() function copies n bytes from memory area src to >> memory area dest. The memory areas must not overlap. Use memmove(3) if >> the memory areas do overlap. > > OK, and shouldn't memcpy optimize that case? Does it usually? As the manpage says "The memory areas must not overlap." , I would expect it does not have to ? -- Best regards, Marek Vasut