I made this patch based on some work that Marko Riedel did. On my
system it doesn't actually increase the speed of drawing that much, but
perhaps it's because my X server is faking 8-bit display and really can
do a fast color lookup. This patch would probably increase the speed of
a remote 8-bit X server as well.