mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-01 14:08:23 -06:00
Review is right that `Stack::push` always returned `Some(())`, so `overflowed` never became true and the whole-instruction discard was dead code. Making it live breaks the page. `an_operator_with_hundreds_of_operands_does_ not_end_the_content` (#4260) puts 300 stray operands before `0 1 0 rg` and asserts the `rg` still reads its own three: with the discard alive the fill stays the previous red, measured as `left: [255, 0, 0]` against `right: [0, 255, 0]`. The ring buffer already gives the right answer. It keeps the newest operands, which are the ones nearest the operator -- its own -- and no operator takes anywhere near 256 of them: `scn` takes one per colourant and ISO 32000 allows a DeviceN space 32. So the strays fall off the back and the operator is applied to its own operands, which is what Acrobat and Chromium do. Dropping the instruction would lose content that is there to be read. The dead branch and the flag are gone, `push` no longer returns a result it cannot produce, and a test pins what the buffer does: the strays are `1` and the operator's own operand is `0`, so the two answers differ. Keeping the oldest operands instead fails it at 256 strays.