+ /* Step forward, calculating the estimated minimum cost to reach each
+ * position. The algorithm may find multiple paths to reach each
+ * position; only the lowest-cost path is saved.
+ *
+ * The progress of the parse is tracked in the @ctx->optimum array, which
+ * for each position contains the minimum cost to reach that position,
+ * the index of the start of the match/literal taken to reach that
+ * position through the minimum-cost path, the offset of the match taken
+ * (not relevant for literals), and the adaptive state that will exist
+ * at that position after the minimum-cost path is taken. The @cur_pos
+ * variable stores the position at which the algorithm is currently
+ * considering coding choices, and the @end_pos variable stores the
+ * greatest position at which the costs of coding choices have been
+ * saved. (Actually, the algorithm guarantees that all positions up to
+ * and including @end_pos are reachable by at least one path.)
+ *
+ * The loop terminates when any one of the following conditions occurs:
+ *
+ * 1. A match with length greater than or equal to @nice_match_length is
+ * found. When this occurs, the algorithm chooses this match
+ * unconditionally, and consequently the near-optimal match/literal
+ * sequence up to and including that match is fully determined and it
+ * can begin returning the match/literal list.
+ *
+ * 2. @cur_pos reaches a position not overlapped by a preceding match.
+ * In such cases, the near-optimal match/literal sequence up to
+ * @cur_pos is fully determined and it can begin returning the
+ * match/literal list.
+ *
+ * 3. Failing either of the above in a degenerate case, the loop
+ * terminates when space in the @ctx->optimum array is exhausted.
+ * This terminates the algorithm and forces it to start returning
+ * matches/literals even though they may not be globally optimal.
+ *
+ * Upon loop termination, a nonempty list of matches/literals will have
+ * been produced and stored in the @optimum array. These
+ * matches/literals are linked in reverse order, so the last thing this
+ * function does is reverse this list and return the first
+ * match/literal, leaving the rest to be returned immediately by
+ * subsequent calls to this function.
+ */
+ cur_pos = 0;