Refactor LZ match reader into a separate function