On Mon, 2004-04-05 at 07:14, Alex Karasulu wrote:
> Hi,
> 
> I was just looking at the digester code as I was writing another incarnation
> of the digester pattern and noticed the pop() and peek() methods do not need
> to catch exceptions.  It is just cheaper to check the size of the stack
> before the pop() or peek() calls and return null instead of just making that
> call surrounded by a catch block.
> 
> You guys want me to just make and commit these changes?  It's not really a
> big deal but thought I'd let you guys know about it.

I don't mind. I don't see any harm, but don't see much benefit either.

What is the performance of a try/catch clause when exceptions aren't
thrown, vs an "if (stack.isEmpty())" which is *always* executed? Is it
truly "cheaper" to use the if?

Of course the current exception-based approach is thread-safe, while an
if-based approach is not, though that is not an issue here.

Regards,

Simon



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to