 At this point, the read pointer could be thought of as only needing to return int("L"/"L"R) + (1 if "L" mod "L"R ≠ 0) times to the start of that single buffered run unit, read "L"R characters (or maybe fewer on the last return), and repeat until a total of "L" characters are read.But mirroring the encoding process, since the pattern is repetitive, the read pointer need only trail in sync with the write pointer by a fixed distance equal to the run length "L"R until "L" characters have been copied to output in total.Considering the above, especially if the compression of data runs is expected to predominate, the window search should begin at the end of the window and proceed backwards, since run patterns, if they exist, will be found first and allow the search to terminate, absolutely if the current maximal matching sequence length is met, or judiciously, if a sufficient length is met, and finally for the simple possibility that the data is more recent and may correlate better with the next input.