luser-dr00g / xpost

A PostScript interpreter in C
Other
98 stars 13 forks source link

Simplify operator execution by pushing args backwards #41

Open luser-dr00g opened 8 years ago

luser-dr00g commented 8 years ago

The function _xpost_operator_push_args_to_hold() does one loop to copy args, and a second loop to pop them from the operand stack.

If we access args in reverse order, this could be simplified to 1 push(pop()) loop.

luser-dr00g commented 3 years ago

Maybe this isn't the best way to improve. If the stack was just contiguous in memory, then we could easily subtract from the pointer in one go. The only complication here is we might be crossing a segment boundary between segments of the stack. But with a special purpose popmany() function, we could eliminate the second loop entirely and all the separate calls to pop().