lib: Improve the performance of memcpy