Avoid some memcpy calls.

Avoid some memcpy calls with assignment. 

/cc @sshirokov