mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-25 02:07:09 -06:00
setdash took a dash array of any length, and the graphics state kept a copy of it. gsave, gstate, currentgstate and setgstate copied the whole pattern with the state, currentdash made an array of it, and each stroke and strokepath copied and scanned it. Each of these counted as one operation against the operation budget. Under a pattern of 1,000,000 entries, a pass of gsave grestore took 0.38 ms of user CPU time, and a pass of strokepath on a line took 2.05 ms. Loops of the two would reach the budget after about 1.6 and 2.8 hours. setdash now raises limitcheck for a pattern of more than 65,535 entries, the most elements an array has in a typical PostScript implementation (PostScript Language Reference, third edition, Table B.1). Saved and copied graphics states share the pattern. setdash and each stroke count each entry they read or copy as one operation, and currentdash counts the array it makes against the memory budget. Under a pattern of 65,535 entries, loops of setdash, currentdash, stroke and strokepath now run out of the operation budget, or the memory budget for currentdash, after 0.08 to 0.31 seconds of user CPU time. Tests: a pattern of 65,535 entries is set, and a pattern of 65,536 entries stops the reading with limitcheck. Under a pattern of 65,535 entries, 4,000,000 passes of gsave grestore and 2,000,000 passes of gstate currentgstate setgstate finish, and loops of setdash, currentdash and strokepath run out of a budget. The test of these loops reads each program on a thread of its own and fails when no result arrives within 20 seconds.