On Tue, 20 Jun 2000, Jeremiah Johnson wrote:
> I am going through the [TODO] sections in the code. In org.jboss.verifier.Section,
>there is the following TODO:
>
> /*
> * [TODO] this can be done more efficiently by creating/storing the string
> * at construction time. We can do this cause at the moment we're
> * still immutable.
> */
>
> My question is, what is the intension of the comment?
Well, the intension for it is to be there to catch my eye whenever I get
back to that part of the code and see if that idea still makes sense a
month later :)
> For example, do you mean that it would be more efficient to just save a
> pre-parsed copy of the section and use this method to just return that
> instance variable rather than rebuilding the section in this
> method?
Yep.
> If that is the case, it seems that it would have taken less time to
> make that change rather than write the comment, so I think that I am
> missing something.
Well, not really. Cause I hadn't figured out whether I should make the
class immutable yet, so I would've had to stop and think about it which
would have distracted me from the real task I was doing at that moment.
So I just dropped a comment on it.
> On the topic of efficiency, you can make that method (String getSection())
> a decent percentage faster without complicating the code by getting rid
> of the if() when placing the delimeter:
>
> Index: Section.java
> ===================================================================
> RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/verifier/Section.java,v
> retrieving revision 1.1
> diff -r1.1 Section.java
> 101c101
> < for (int i = 0; i < section.length; ++i) {
> ---
> > for (int i = 0; i < (section.length - 1); ++i) {
> 103,105c103
> <
> < if (i + 1 < section.length)
> < buffer.append(".");
> ---
> > buffer.append(DELIMETER);
> 106a105
> > buffer.append(section[section.length - 1]);
Correct.
However, you may have noticed that even though this particular class lives
in the CVS, it's not even used by anyone yet. I just wanted to put some of
the ideas that came up with a few emails with Aaron (thanks again,
btw) into concrete code before I forget them, and I hate having my classes
loitering around in the corner of my HD instead of placing them in the
security of a versioning system :)
Thanks for the comments, some major rework coming up on the messaging
(that section class is part of, Aaron knows :) so expect that code to be
mutating for a while.
-- Juha