Avoid some memcpy when not necessary

Change-Id: I9b838fc8392bc61be4ed911fb1423a1e97af2356