Avoid doing redundant memory operations
commit147c95b64210c68f53e3e7955dfdf353a33eb259
authormalc <av1474@comtv.ru>
Sat, 2 Oct 2010 13:45:21 +0000 (2 17:45 +0400)
committermalc <av1474@comtv.ru>
Sat, 2 Oct 2010 13:45:21 +0000 (2 17:45 +0400)
tree84b03947ce0db9613fe2505315d3fad675ddfdcd
parent41afd3c908a7550b93a4516379d9704fab120506
Avoid doing redundant memory operations

Memory for pixmaps comes either from mmap or sbrk, we clear that
memory with 0xff to have a default white fully transparent page, but
if the memory came to us via mmap it was zeroed (or will be on page
fault) ditto fresh sbrk obtained block, so we are effectively touching
the same (possibly very large) memory block twice for no good reason.

Glibc/ptmalloc even goes as far as to zero the freed blocks, so
there's seemingly no way to escape this.

So instead of freeing a page we store it in hope that the next draw
operation will pick it up and it will match the constraints and we
will save on "memset".

This also uncovered a bug, pagedim pointer which is stored in the page
structure is unstable, so just use copy of the structure instead.
link.c