in reply to Getting the size of the call stack (efficiently)

Does anyone know of a more efficient method for finding just the stack depth without using multiple calls to caller() each time you need that number?

I think you'd would have to implement it in XS and adapt the underlying code for caller. Looking at pp_ctl.c in the source, it looks like caller is just walking the stack itself, but someone with more knowledge of XS and Perl guts would have to advise you on just what you need to do.

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Replies are listed 'Best First'.
Re^2: Getting the size of the call stack (efficiently)
by DrWhy (Chaplain) on Mar 01, 2007 at 00:18 UTC
    Thanks for the pointer. I've just tried an implementation of my module using the simpleminded algorithm and I find it's working acceptably quickly, so I don't have the motivation at this point to delve into XS, but I'll keep that in mind for later maybe.

    --DrWhy

    "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."