This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch: Remove exception catching from normal path in Arrays.equals.
- From: Mohan Embar <gnustuff at thisiscool dot com>
- To: tromey at redhat dot com
- Cc: java-patches at gcc dot gnu dot org
- Date: Sat, 06 Sep 2003 08:33:58 -0500
- Subject: Re: Patch: Remove exception catching from normal path in Arrays.equals.
- Reply-to: gnustuff at thisiscool dot com
Tom,
While we're on this subject, there are myriad places (natClass.cc,
natRuntime.cc, natArray.cc, natConstructor.cc, natField.cc, natMethod.cc,
natResourceBundle.cc) where gnu.gcj.StackTrace is being used
like this (example from natArray.cc):
try
{
for (int i = 1; !caller; i++)
{
caller = t->classAt (i);
}
caller_loader = caller->getClassLoaderInternal();
}
catch (::java::lang::ArrayIndexOutOfBoundsException *e)
{
}
Unless I'm not understanding something correctly, it seems to me that this
variant is much easier to read:
for (int i = 1; !caller && i < t->length (); ++i)
{
caller = t->classAt (i);
}
if (caller)
caller_loader = caller->getClassLoaderInternal ();
And this one would be even better:
Class* caller = t->tryTofindFirstNonNullClassStartingAtIndex (1);
if (caller)
caller_loader = caller->getClassLoaderInternal ();
...where tryTofindFirstNonNullClassStartingAtIndex, a new method of
StackTrace, is replaced by a better name (I'm bad at names).
I've pondered submitting a patch for this, but haven't, because
I don't think that the code in question suffers from bad performance.
The patch would be mostly aesthetic.
Should I submit a patch anyway? Or is this not worth it?
-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/