SD cards (especially the cheaper ones) have frequently an okay read performance but are slow to write to. If you're restoring an image of a Raspberry Pi, for example, chances are that most blocks will be untouched since the backup.
diffcat first reads blocks from the output file to determine if they need
overwriting. If they don't, it skips them.
On a ThinkPad laptop with a cheap SD card:
pixz -d image.xz > /dev/mmcblk0: 41 minutespixz -d image.xz | diffcat /dev/mmcblk0: 6 minutes
(The diffcat call ran on an already identical image so it performed no writes.)
$ make
$ pixz -d image.xz | diffcat /dev/mmcblk0- you can
#define DEBUGto get a (very verbose) description of the process - you can re-
#define BLOCKSIZEto use non-4K blocks