[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cp-patches] Patch: Opening RandomAccessFiles requires excessive per
From: |
Archie Cobbs |
Subject: |
Re: [cp-patches] Patch: Opening RandomAccessFiles requires excessive permission |
Date: |
Tue, 06 Dec 2005 10:00:23 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.3) Gecko/20041129 |
Christian Thalinger wrote:
I don't know if this is performance critical code or is used very often,
but this seems to be a special case and i'd suggest something like:
public void write (int oneByte) throws IOException
{
try {
out.write(oneByte);
return;
} catch (NullPointerException e) {
throw new IOException("Bad file descriptor");
}
}
I'll not win a beautiful-code prize, but will be compiled to the fastest
code.
That's getting into the micro-optimzation realm, which is
fraught with danger and mistaken assumptions :-) E.g., on
some machines the time overhead of setting up a try/catch in
a method that wouldn't otherwise have one is higher than
the single comparison required to test for null. In particular,
any interpreter is going to have to test for null anyway,
so the second time it's already in cache, blah blah, etc.
Not to mention that the space overhead of a try/catch (vs. none)
will probably be higher too. So IMHO it's better to avoid
too much of this kind of thing (unless it actually makes the
source code clearer (don't think so in this case)).
Apologies for the minor IMHO rant.. :-)
-Archie
__________________________________________________________________________
Archie Cobbs * CTO, Awarix * http://www.awarix.com
- [cp-patches] Patch: Opening RandomAccessFiles requires excessive permission, Gary Benson, 2005/12/05
- Re: [cp-patches] Patch: Opening RandomAccessFiles requires excessive permission, David Daney, 2005/12/05
- Re: [cp-patches] Patch: Opening RandomAccessFiles requires excessive permission, Christian Thalinger, 2005/12/06
- Re: [cp-patches] Patch: Opening RandomAccessFiles requires excessive permission,
Archie Cobbs <=
- Re: [cp-patches] Patch: Opening RandomAccessFiles requires excessive permission, Christian Thalinger, 2005/12/06
- Re: [cp-patches] Patch: Opening RandomAccessFiles requires excessive permission, Archie Cobbs, 2005/12/06
- Re: [cp-patches] Patch: Opening RandomAccessFiles requires excessive permission, Christian Thalinger, 2005/12/06
- Re: [cp-patches] Patch: Opening RandomAccessFiles requires excessive permission, Archie Cobbs, 2005/12/06
- Re: [cp-patches] Patch: Opening RandomAccessFiles requires excessive permission, Tom Tromey, 2005/12/06
- Re: [cp-patches] Patch: Opening RandomAccessFiles requires excessive permission, Gary Benson, 2005/12/07
- [cp-patches] FYI: Opening RandomAccessFiles requires excessive permission, Gary Benson, 2005/12/07
- Re: [cp-patches] FYI: Opening RandomAccessFiles requires excessive permission, Tom Tromey, 2005/12/07
- Re: [cp-patches] Patch: Opening RandomAccessFiles requires excessive permission, David Daney, 2005/12/07
- Re: [cp-patches] Patch: Opening RandomAccessFiles requires excessive permission, Gary Benson, 2005/12/07