[email protected]
[Top] [All Lists]

Re: bytecount as String and prefix length

Subject: Re: bytecount as String and prefix length
From: Doug Cutting
Date: Tue, 01 Nov 2005 09:39:39 -0800
Marvin Humphrey wrote:
I think it's time to throw in the towel.
Please don't give up.  I think you're quite close.

I would be careful using CharBuffer instead of char[] unless you're sure all methods you call are very efficient. You could try avoiding CharBuffer by adding something (ugly) like an int[]charLength parameter where the length is stored, then simply return the char[], in case you had to re-allocate.
Using an exception for control flow is not only considered bad style,
but is also a performance pitfall. A catch that is unused is free, but
catching and throwing exceptions is expensive.
A complete diff would make it easier to see if there's something else
which may be slowing things, e.g., inadvertantly allocating something
for each call. Also, someone else could try to tune it more.
Have you profiled this? Sun's built-in profiler can be useful. It can
give you allocation counts, so you can see if you're allocating
significantly more objects. It also gives call counts (in the old 'java
-prof' mode) which are useful. It slows things so much that I find
relative performance of methods to be nearly worthless, but call and
allocation counts can point out problems.


To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

<Prev in Thread] Current Thread [Next in Thread>