Benjamin Goldberg <[EMAIL PROTECTED]> wrote: > Looking over the code for these ops, ISTM that the stack_push and > stack_pop functions which implements them is too bloated.
Yep. > How often, in practice, is the Stack_cleanup_method cleanup thing > needed? I don't know and can imagine a usage for the cleanup code. A stack_push takes 45 instructions, the flag test is 5, setting the cleanup is 2 (i386). So we could save 7 of 45. > Wouldn't it be faster to test whether or not there's a cleanup entry at > pop time, by comparing that field with NULL, than checking whether or > not there's a bit set in flags? Yep the flags field is totally redundant. > Possibly, the overhead of doing the tests for a cleanup function could > be avoided by making a new Stack_entry_type value, soley for cleanup > functions. Still better. > For a more revolutionary idea for speeding up save[insp] and > restore[insp], consider having a seperate stack for each type, This would save another 7 instructions (setting the type and the switch). OTOH it would increase overall code size. I don't know if its better. I'd first toss the cleanup code and - if we ever need it - go for separate entry_types that do cleanup too. leo