Data Compaction - Compression without Decompression

Came across an article about how to use overlapping parts of arrays to minimize memory footprint.
The technique is useful for non changing arrays e.g. lookup tables (progmem) when you run out of memory.
(yes it uses pointers)

The technique boils down to this . e.g. you have two array's
A[] = { 1,2 3,4,5,6,7 8, 9, 10} // 10 bytes
B[] = { 7, 8, 9, 10, 11,12, 13} // 7 bytes

you can replace this with
X[]= { 1,2 3,4,5,6,7 8, 9, 10, 11,12, 13} // 12 bytes
*A = &X[0]; // 2 bytes
*B = &X[6]; //2 bytes

The 2nd storage structure gains one byte (just as example)
conclusion

  • break even if overlap == pointersize
  • gain if overlap > pointersize

Still interesting technique for those approaching the 32K limit of their UNO

The article - [1402.2508v1] Data Compaction - Compression without Decompression -