You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Bill Dubin <bi...@thedubins.com> on 2007/01/25 21:48:51 UTC

isBlank implementation question for educational purposes, please

Below are two implementations for the isBlank() method.  One is from the
Commons Lang and the other was coded by a colleague of mine and he claims
his way is better and faster.  

 

I would like to understand how or why his or the Commons approach is better.
Maybe one is not better, but I still would like to have an understanding of
how and/or why someone would choose one way over the other so I can further
my software development skillset.  Maybe there are ramifications one way or
the other that I'm not seeing and someone can shed some light on for me?

 

My only motivation for this question is to learn and understand this stuff
better.  Thank you for any explanation you can provide!!  I do appreciate
any assistance or lessons!!

 

//From Commons project

public static boolean isBlank(String str) {

        int strLen;

        if (str == null || (strLen = str.length()) == 0) {

            return true;

        }

        for (int i = 0; i < strLen; i++) {

            if ((Character.isWhitespace(str.charAt(i)) == false)) {

                return false;

            }

        }

        return true;

 

 

Versus this way of doing the test:

 

 

 

//Modified with faster logic according to one of our developers  

public static boolean isBlank(String str){

      int strLen;

      if ((str == null) || ((strLen = str.length()) == 0))  {

            return true;

      }

      else  {

      str = str.trim();

      if (str.length() == 0)  {

                  return true;

            }

            else        {

                  return false;

            }

      }

}

 


RE: isBlank implementation question for educational purposes, please

Posted by Bill Dubin <bi...@thedubins.com>.
Yes, makes perfect sense!  Thank you!

Bill

-----Original Message-----
From: Paul J DeCoursey [mailto:paul@decoursey.net] 
Sent: Thursday, January 25, 2007 3:00 PM
To: Jakarta Commons Users List
Subject: Re: isBlank implementation question for educational purposes,
please

His way will only be faster if the string is blank.  If the string is 
not blank then the trim function will chew up several processing cycles. 
An example, say we pass in " dog"...

trim will trim off the first character and check to see if there are 
more to trim on the beginning and then check the end of the string.  The 
commons method will return false after checking only two characters. 
make sense?

Bill Dubin wrote:
> Below are two implementations for the isBlank() method.  One is from the
> Commons Lang and the other was coded by a colleague of mine and he claims
> his way is better and faster.  
>
>  
>
> I would like to understand how or why his or the Commons approach is
better.
> Maybe one is not better, but I still would like to have an understanding
of
> how and/or why someone would choose one way over the other so I can
further
> my software development skillset.  Maybe there are ramifications one way
or
> the other that I'm not seeing and someone can shed some light on for me?
>
>  
>
> My only motivation for this question is to learn and understand this stuff
> better.  Thank you for any explanation you can provide!!  I do appreciate
> any assistance or lessons!!
>
>  
>
> //From Commons project
>
> public static boolean isBlank(String str) {
>
>         int strLen;
>
>         if (str == null || (strLen = str.length()) == 0) {
>
>             return true;
>
>         }
>
>         for (int i = 0; i < strLen; i++) {
>
>             if ((Character.isWhitespace(str.charAt(i)) == false)) {
>
>                 return false;
>
>             }
>
>         }
>
>         return true;
>
>  
>
>  
>
> Versus this way of doing the test:
>
>  
>
>  
>
>  
>
> //Modified with faster logic according to one of our developers  
>
> public static boolean isBlank(String str){
>
>       int strLen;
>
>       if ((str == null) || ((strLen = str.length()) == 0))  {
>
>             return true;
>
>       }
>
>       else  {
>
>       str = str.trim();
>
>       if (str.length() == 0)  {
>
>                   return true;
>
>             }
>
>             else        {
>
>                   return false;
>
>             }
>
>       }
>
> }
>
>  
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: isBlank implementation question for educational purposes, please

Posted by Henri Yandell <fl...@gmail.com>.
Most importantly - they have different functionality.

If you check the javadoc, trim() uses Character.isSpace, and also
trims control characters. Character.isWhiteSpace is the newer version
of isSpace and checks for a greater number of characters (most
importantly Unicode space characters).

Hen

On 1/25/07, Bill Dubin <bi...@thedubins.com> wrote:
> Yes, I do want to learn and I appreciate your information.
>
> -----Original Message-----
> From: Aaron Freeman [mailto:aaron@sendthisfile.com]
> Sent: Thursday, January 25, 2007 3:53 PM
> To: 'Jakarta Commons Users List'
> Subject: RE: isBlank implementation question for educational purposes,
> please
>
> Actually his will be slower even if it's blank.  Strings are immutable
> (meaning they can't be changed), so under the hood the trim() method will
> have the overhead of creating a new String object.  Then it will have to
> cycle through each character in the original String to copy the non-trimmed
> characters into the new String instance.  So even if it was blank it has the
> overhead of checking every character just to copy them into the new String
> that it will return.
>
> Normally this would be a detail not worth pointing out since Paul's answer
> was sufficent to show which is faster, but you did say you wanted to learn
> the in's and out's.
>
> -a
>
> > -----Original Message-----
> > From: Paul J DeCoursey [mailto:paul@decoursey.net]
> > Sent: Thursday, January 25, 2007 3:00 PM
> > To: Jakarta Commons Users List
> > Subject: Re: isBlank implementation question for educational
> > purposes, please
> >
> > His way will only be faster if the string is blank.  If the
> > string is not blank then the trim function will chew up
> > several processing cycles.
> > An example, say we pass in " dog"...
> >
> > trim will trim off the first character and check to see if
> > there are more to trim on the beginning and then check the
> > end of the string.  The commons method will return false
> > after checking only two characters.
> > make sense?
> >
> > Bill Dubin wrote:
> > > Below are two implementations for the isBlank() method.
> > One is from
> > > the Commons Lang and the other was coded by a colleague of
> > mine and he
> > > claims his way is better and faster.
> > >
> > >
> > >
> > > I would like to understand how or why his or the Commons
> > approach is better.
> > > Maybe one is not better, but I still would like to have an
> > > understanding of how and/or why someone would choose one
> > way over the
> > > other so I can further my software development skillset.
> > Maybe there
> > > are ramifications one way or the other that I'm not seeing
> > and someone can shed some light on for me?
> > >
> > >
> > >
> > > My only motivation for this question is to learn and
> > understand this
> > > stuff better.  Thank you for any explanation you can
> > provide!!  I do
> > > appreciate any assistance or lessons!!
> > >
> > >
> > >
> > > //From Commons project
> > >
> > > public static boolean isBlank(String str) {
> > >
> > >         int strLen;
> > >
> > >         if (str == null || (strLen = str.length()) == 0) {
> > >
> > >             return true;
> > >
> > >         }
> > >
> > >         for (int i = 0; i < strLen; i++) {
> > >
> > >             if ((Character.isWhitespace(str.charAt(i)) == false)) {
> > >
> > >                 return false;
> > >
> > >             }
> > >
> > >         }
> > >
> > >         return true;
> > >
> > >
> > >
> > >
> > >
> > > Versus this way of doing the test:
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > //Modified with faster logic according to one of our developers
> > >
> > > public static boolean isBlank(String str){
> > >
> > >       int strLen;
> > >
> > >       if ((str == null) || ((strLen = str.length()) == 0))  {
> > >
> > >             return true;
> > >
> > >       }
> > >
> > >       else  {
> > >
> > >       str = str.trim();
> > >
> > >       if (str.length() == 0)  {
> > >
> > >                   return true;
> > >
> > >             }
> > >
> > >             else        {
> > >
> > >                   return false;
> > >
> > >             }
> > >
> > >       }
> > >
> > > }
> > >
> > >
> > >
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: isBlank implementation question for educational purposes, please

Posted by David Tonhofer <d....@m-plify.com>.
Bill Dubin wrote:
> Yes, I do want to learn and I appreciate your information.
>
> -

Two cents worth: just measure the performance on a big input set for 
Ultimate Truth (tm)


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


RE: isBlank implementation question for educational purposes, please

Posted by Steffen Heil <li...@steffen-heil.de>.
Hi

> It is still constructing a new object, which is expensive.

It has constant runtime.
Remember: Java uses a young collection for this. (If at all, your VM might
optimize this to a stack object, which is never allocated.)

Regards,
  Steffen

Re: isBlank implementation question for educational purposes, please

Posted by Paul J DeCoursey <pa...@decoursey.net>.
It is still constructing a new object, which is expensive.

Tahir Akhtar wrote:
> You are right!!! It even says that in comments above constructor. 
>
>     public String substring(int beginIndex, int endIndex) {
> 	if (beginIndex < 0) {
> 	    throw new StringIndexOutOfBoundsException(beginIndex);
> 	}
> 	if (endIndex > count) {
> 	    throw new StringIndexOutOfBoundsException(endIndex);
> 	}
> 	if (beginIndex > endIndex) {
> 	    throw new StringIndexOutOfBoundsException(endIndex -
> beginIndex);
> 	}
> 	return ((beginIndex == 0) && (endIndex == count)) ? this :
> 	    new String(offset + beginIndex, endIndex - beginIndex, value);
>     }
>     // Package private constructor which shares value array for speed.
>     String(int offset, int count, char value[]) {
> 	this.value = value;
> 	this.offset = offset;
> 	this.count = count;
>     }
>
> -----Original Message-----
> From: Steffen Heil [mailto:lists@steffen-heil.de] 
> Sent: Friday, January 26, 2007 3:04 PM
> To: 'Jakarta Commons Users List'
> Subject: RE: isBlank implementation question for educational purposes,
> please
>
> Hi
>
>   
>> Actually his will be slower even if it's blank.  Strings are 
>> immutable (meaning they can't be changed), so under the hood 
>> the trim() method will have the overhead of creating a new 
>> String object.  Then it will have to cycle through each 
>> character in the original String to copy the non-trimmed 
>> characters into the new String instance.  So even if it was 
>> blank it has the overhead of checking every character just to 
>> copy them into the new String that it will return.
>>     
>
> No.
> substring does not copy Strings.
> It just returns new String objects, that refer to the original char[], but
> have different offset and length values.
>
> I haven't looked at the implementation right now, but I assume, it justs
> counts isSpace(s) from the start and from the end and calls substring.
> Therefor it's execution time should be linear to the amount of spaces at the
> beginning and end and be independant from the length of the rest of the
> String.
>
> Regards,
>   Steffen
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


RE: isBlank implementation question for educational purposes, please

Posted by Tahir Akhtar <ta...@spectrum-tech.com>.
You are right!!! It even says that in comments above constructor. 

    public String substring(int beginIndex, int endIndex) {
	if (beginIndex < 0) {
	    throw new StringIndexOutOfBoundsException(beginIndex);
	}
	if (endIndex > count) {
	    throw new StringIndexOutOfBoundsException(endIndex);
	}
	if (beginIndex > endIndex) {
	    throw new StringIndexOutOfBoundsException(endIndex -
beginIndex);
	}
	return ((beginIndex == 0) && (endIndex == count)) ? this :
	    new String(offset + beginIndex, endIndex - beginIndex, value);
    }
    // Package private constructor which shares value array for speed.
    String(int offset, int count, char value[]) {
	this.value = value;
	this.offset = offset;
	this.count = count;
    }

-----Original Message-----
From: Steffen Heil [mailto:lists@steffen-heil.de] 
Sent: Friday, January 26, 2007 3:04 PM
To: 'Jakarta Commons Users List'
Subject: RE: isBlank implementation question for educational purposes,
please

Hi

> Actually his will be slower even if it's blank.  Strings are 
> immutable (meaning they can't be changed), so under the hood 
> the trim() method will have the overhead of creating a new 
> String object.  Then it will have to cycle through each 
> character in the original String to copy the non-trimmed 
> characters into the new String instance.  So even if it was 
> blank it has the overhead of checking every character just to 
> copy them into the new String that it will return.

No.
substring does not copy Strings.
It just returns new String objects, that refer to the original char[], but
have different offset and length values.

I haven't looked at the implementation right now, but I assume, it justs
counts isSpace(s) from the start and from the end and calls substring.
Therefor it's execution time should be linear to the amount of spaces at the
beginning and end and be independant from the length of the rest of the
String.

Regards,
  Steffen



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


RE: isBlank implementation question for educational purposes, please

Posted by Steffen Heil <li...@steffen-heil.de>.
Hi

> Actually his will be slower even if it's blank.  Strings are 
> immutable (meaning they can't be changed), so under the hood 
> the trim() method will have the overhead of creating a new 
> String object.  Then it will have to cycle through each 
> character in the original String to copy the non-trimmed 
> characters into the new String instance.  So even if it was 
> blank it has the overhead of checking every character just to 
> copy them into the new String that it will return.

No.
substring does not copy Strings.
It just returns new String objects, that refer to the original char[], but
have different offset and length values.

I haven't looked at the implementation right now, but I assume, it justs
counts isSpace(s) from the start and from the end and calls substring.
Therefor it's execution time should be linear to the amount of spaces at the
beginning and end and be independant from the length of the rest of the
String.

Regards,
  Steffen

RE: isBlank implementation question for educational purposes, please

Posted by Bill Dubin <bi...@thedubins.com>.
Yes, I do want to learn and I appreciate your information.

-----Original Message-----
From: Aaron Freeman [mailto:aaron@sendthisfile.com] 
Sent: Thursday, January 25, 2007 3:53 PM
To: 'Jakarta Commons Users List'
Subject: RE: isBlank implementation question for educational purposes,
please

Actually his will be slower even if it's blank.  Strings are immutable
(meaning they can't be changed), so under the hood the trim() method will
have the overhead of creating a new String object.  Then it will have to
cycle through each character in the original String to copy the non-trimmed
characters into the new String instance.  So even if it was blank it has the
overhead of checking every character just to copy them into the new String
that it will return.

Normally this would be a detail not worth pointing out since Paul's answer
was sufficent to show which is faster, but you did say you wanted to learn
the in's and out's. 

-a

> -----Original Message-----
> From: Paul J DeCoursey [mailto:paul@decoursey.net] 
> Sent: Thursday, January 25, 2007 3:00 PM
> To: Jakarta Commons Users List
> Subject: Re: isBlank implementation question for educational 
> purposes, please
> 
> His way will only be faster if the string is blank.  If the 
> string is not blank then the trim function will chew up 
> several processing cycles. 
> An example, say we pass in " dog"...
> 
> trim will trim off the first character and check to see if 
> there are more to trim on the beginning and then check the 
> end of the string.  The commons method will return false 
> after checking only two characters. 
> make sense?
> 
> Bill Dubin wrote:
> > Below are two implementations for the isBlank() method.  
> One is from 
> > the Commons Lang and the other was coded by a colleague of 
> mine and he 
> > claims his way is better and faster.
> >
> >  
> >
> > I would like to understand how or why his or the Commons 
> approach is better.
> > Maybe one is not better, but I still would like to have an 
> > understanding of how and/or why someone would choose one 
> way over the 
> > other so I can further my software development skillset.  
> Maybe there 
> > are ramifications one way or the other that I'm not seeing 
> and someone can shed some light on for me?
> >
> >  
> >
> > My only motivation for this question is to learn and 
> understand this 
> > stuff better.  Thank you for any explanation you can 
> provide!!  I do 
> > appreciate any assistance or lessons!!
> >
> >  
> >
> > //From Commons project
> >
> > public static boolean isBlank(String str) {
> >
> >         int strLen;
> >
> >         if (str == null || (strLen = str.length()) == 0) {
> >
> >             return true;
> >
> >         }
> >
> >         for (int i = 0; i < strLen; i++) {
> >
> >             if ((Character.isWhitespace(str.charAt(i)) == false)) {
> >
> >                 return false;
> >
> >             }
> >
> >         }
> >
> >         return true;
> >
> >  
> >
> >  
> >
> > Versus this way of doing the test:
> >
> >  
> >
> >  
> >
> >  
> >
> > //Modified with faster logic according to one of our developers
> >
> > public static boolean isBlank(String str){
> >
> >       int strLen;
> >
> >       if ((str == null) || ((strLen = str.length()) == 0))  {
> >
> >             return true;
> >
> >       }
> >
> >       else  {
> >
> >       str = str.trim();
> >
> >       if (str.length() == 0)  {
> >
> >                   return true;
> >
> >             }
> >
> >             else        {
> >
> >                   return false;
> >
> >             }
> >
> >       }
> >
> > }
> >
> >  
> >
> >
> >   
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


RE: isBlank implementation question for educational purposes, please

Posted by Aaron Freeman <aa...@sendthisfile.com>.
Actually his will be slower even if it's blank.  Strings are immutable
(meaning they can't be changed), so under the hood the trim() method will
have the overhead of creating a new String object.  Then it will have to
cycle through each character in the original String to copy the non-trimmed
characters into the new String instance.  So even if it was blank it has the
overhead of checking every character just to copy them into the new String
that it will return.

Normally this would be a detail not worth pointing out since Paul's answer
was sufficent to show which is faster, but you did say you wanted to learn
the in's and out's. 

-a

> -----Original Message-----
> From: Paul J DeCoursey [mailto:paul@decoursey.net] 
> Sent: Thursday, January 25, 2007 3:00 PM
> To: Jakarta Commons Users List
> Subject: Re: isBlank implementation question for educational 
> purposes, please
> 
> His way will only be faster if the string is blank.  If the 
> string is not blank then the trim function will chew up 
> several processing cycles. 
> An example, say we pass in " dog"...
> 
> trim will trim off the first character and check to see if 
> there are more to trim on the beginning and then check the 
> end of the string.  The commons method will return false 
> after checking only two characters. 
> make sense?
> 
> Bill Dubin wrote:
> > Below are two implementations for the isBlank() method.  
> One is from 
> > the Commons Lang and the other was coded by a colleague of 
> mine and he 
> > claims his way is better and faster.
> >
> >  
> >
> > I would like to understand how or why his or the Commons 
> approach is better.
> > Maybe one is not better, but I still would like to have an 
> > understanding of how and/or why someone would choose one 
> way over the 
> > other so I can further my software development skillset.  
> Maybe there 
> > are ramifications one way or the other that I'm not seeing 
> and someone can shed some light on for me?
> >
> >  
> >
> > My only motivation for this question is to learn and 
> understand this 
> > stuff better.  Thank you for any explanation you can 
> provide!!  I do 
> > appreciate any assistance or lessons!!
> >
> >  
> >
> > //From Commons project
> >
> > public static boolean isBlank(String str) {
> >
> >         int strLen;
> >
> >         if (str == null || (strLen = str.length()) == 0) {
> >
> >             return true;
> >
> >         }
> >
> >         for (int i = 0; i < strLen; i++) {
> >
> >             if ((Character.isWhitespace(str.charAt(i)) == false)) {
> >
> >                 return false;
> >
> >             }
> >
> >         }
> >
> >         return true;
> >
> >  
> >
> >  
> >
> > Versus this way of doing the test:
> >
> >  
> >
> >  
> >
> >  
> >
> > //Modified with faster logic according to one of our developers
> >
> > public static boolean isBlank(String str){
> >
> >       int strLen;
> >
> >       if ((str == null) || ((strLen = str.length()) == 0))  {
> >
> >             return true;
> >
> >       }
> >
> >       else  {
> >
> >       str = str.trim();
> >
> >       if (str.length() == 0)  {
> >
> >                   return true;
> >
> >             }
> >
> >             else        {
> >
> >                   return false;
> >
> >             }
> >
> >       }
> >
> > }
> >
> >  
> >
> >
> >   
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: isBlank implementation question for educational purposes, please

Posted by Paul J DeCoursey <pa...@decoursey.net>.
His way will only be faster if the string is blank.  If the string is 
not blank then the trim function will chew up several processing cycles. 
An example, say we pass in " dog"...

trim will trim off the first character and check to see if there are 
more to trim on the beginning and then check the end of the string.  The 
commons method will return false after checking only two characters. 
make sense?

Bill Dubin wrote:
> Below are two implementations for the isBlank() method.  One is from the
> Commons Lang and the other was coded by a colleague of mine and he claims
> his way is better and faster.  
>
>  
>
> I would like to understand how or why his or the Commons approach is better.
> Maybe one is not better, but I still would like to have an understanding of
> how and/or why someone would choose one way over the other so I can further
> my software development skillset.  Maybe there are ramifications one way or
> the other that I'm not seeing and someone can shed some light on for me?
>
>  
>
> My only motivation for this question is to learn and understand this stuff
> better.  Thank you for any explanation you can provide!!  I do appreciate
> any assistance or lessons!!
>
>  
>
> //From Commons project
>
> public static boolean isBlank(String str) {
>
>         int strLen;
>
>         if (str == null || (strLen = str.length()) == 0) {
>
>             return true;
>
>         }
>
>         for (int i = 0; i < strLen; i++) {
>
>             if ((Character.isWhitespace(str.charAt(i)) == false)) {
>
>                 return false;
>
>             }
>
>         }
>
>         return true;
>
>  
>
>  
>
> Versus this way of doing the test:
>
>  
>
>  
>
>  
>
> //Modified with faster logic according to one of our developers  
>
> public static boolean isBlank(String str){
>
>       int strLen;
>
>       if ((str == null) || ((strLen = str.length()) == 0))  {
>
>             return true;
>
>       }
>
>       else  {
>
>       str = str.trim();
>
>       if (str.length() == 0)  {
>
>                   return true;
>
>             }
>
>             else        {
>
>                   return false;
>
>             }
>
>       }
>
> }
>
>  
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: isBlank implementation question for educational purposes, please

Posted by Andrew Shirley <ak...@decisionsoft.co.uk>.
On Thu, Jan 25, 2007 at 02:48:51PM -0600, Bill Dubin wrote:
> My only motivation for this question is to learn and understand this stuff
> better.  Thank you for any explanation you can provide!!  I do appreciate
> any assistance or lessons!!
> 

If anything should be learned form this, or similar, threads it is that
however much we might think we know about how a piece of code will work
at a low level and which will use the most processor cycles etc, we
should write the code which is semantically correct and maintainable
and, if it is needed, optimise after profilling.

It would be interesting to see if the other version was written
independatly from the commons version or as an attempt at optimisation
and if the later, wether it needs to be optimised and whether the
semantic differences were intentional.

Andrew

-- 
Andrew Shirley, Client Services        DecisionSoft Limited
+44-1865-203192                        http://www.decisionsoft.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org