Performance of exception handling

Alexander aldem+dmars at nk7.net
Tue Apr 26 06:57:42 PDT 2011


On 26.04.2011 15:20, Daniel Gibson wrote:

> It'd be nice to have fast(er) exceptions and still be able to get
> backtraces for uncaught exceptions (or even for caught ones on demand).

  Well, quick-and-dirty solution for this (uncaught only, though) follows. Not very nice, but "works for me" :)

---snip---
import core.runtime;

int
main(string[] argv)
{
        auto oldTraceHandler = Runtime.traceHandler;
        Runtime.traceHandler = null;
        try {
                return try_main(argv);
        } catch (Throwable ex) {
                Runtime.traceHandler = oldTraceHandler;
                throw ex;
        }
}

int
try_main(string[] argv)
{
// Real main() code
}
---snip---


More information about the Digitalmars-d mailing list