On Thu, Mar 16, 2000 at 11:25:26AM +0100, Ralf Nieser wrote:
> >21      case '"':  buf.append( "\\\"" ); break;                      // !
> >22      case '\\': buf.append( "\\\\" ); break;                      // !   
> >23      default:   buf.append( ch );     break;
> 
> 2. :line (21,22)
> If you look at the source of java.lang.StringBuffer it seems that
> buf.append( '\\' ).append( '\"' );    is cheaper than a
> buf.append( "\\\"" );


Regardless of the append implimentation of append, appending a char
instead of a string saves you an object creation as well.  Since this
code will create a new String object for each append.

Brad
-- 
--- There are two kinds of knowledge, you either know the answer or
                        you know where to find it
                      -Kane, Johnson, and anonymous

Reply via email to