Source

Branch

1/ @mirbacx

some distinction between allocating new memory, copying src->dst, and then freeing src. copying/moving is expensive.

updating pointers (to point to elsewhere in already allocated memory) is different.

there’s also the matter of data locality. the cpu prefetches data (from RAM) onto caches. only so much can fit closest to the CPU (L1), so you don’t want your algos accessing memory all over the place (eg, linked lists). “cache misses”