Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: The performance cost of using exceptions?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Markus Mottl <mottl@m...>
Subject: Re: The performance cost of using exceptions?
> How about having a compiler that detects this pattern and emits the
> necessary pointer comparisons?  Then you could write your code cleanly
> (without exceptions, flags or comparisons), and the compiler can emit
> whatever code is most efficient for its runtime.

One could surely do this, especially if the compiler "sees" that only one
or a few arguments of a constructor change: then checking for physical
identity would allow it to return the "original" value.

But I am not sure whether this is generally a good idea, because the
compiler cannot predict runtime behaviour: it may well be that you use sets
without ever inserting already existing elements into them. Then all these
checks are superfluous.

The good thing about the version with exceptions is that you do not need
the checks for physical equality anymore, which quickly pays with
increasing data amounts and is not really so "unclean".

Best regards,
Markus Mottl

-- 
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl