The compiler generates a new string buffer for each concat, so for multiple 
concats, it's more efficient to do it manually.

-----Original Message-----
From: Vincent Siveton [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 23, 2008 6:17 PM
To: Maven Developers List
Subject: Re: svn commit: r678721 - 
/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java

Hi Hervé,

2008/7/23, Hervé BOUTEMY <[EMAIL PROTECTED]>:
> Sorry, wasn't meant for the list...
>  Now it is on the list, I'll translate (anybody here not speaking french?)
>
>  I was asking Vincent the reason to use a StringBuffer and append methods, 
> when
>  the compiler could automatically do the job. Just to understand and learn a
>  new trick.

Yes the compiler could create compile time constant.
My reasoning is more a code readability (try to reformat the old
snippet with you favourite IDE) and to make difference between
constant and runtime constant.

I could change it if you prefer.

Cheers,

Vincent

>  regards,
>
>  Hervé
>
>  Le mercredi 23 juillet 2008, Hervé BOUTEMY a écrit :
>
> > Salut Vincent,
>  >
>  > Tiens, tu tiens à utiliser un StringBuffer au lieu de laisser le
>  > compilateur faire le boulot. Je suppose qu'il y a une raison ?
>  >
>  > A+
>  >
>  > Hervé
>  >
>  > Le mardi 22 juillet 2008, vous avez écrit :
>  > > Author: vsiveton
>  > > Date: Tue Jul 22 04:39:06 2008
>  > > New Revision: 678721
>  > >
>  > > URL: http://svn.apache.org/viewvc?rev=678721&view=rev
>  > > Log:
>  > > o minor changes due to r678198
>  > >
>  > > Modified:
>  > >
>  > > maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/a
>  > >pa
>  > > che/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.j
>  > >ava
>  > >
>  > > Modified:
>  > > maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/a
>  > >pa
>  > > che/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.j
>
> > >ava URL:
>
> > > http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-repor
>  > >ts
>  > > -plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/re
>
> > >nde rer/DependenciesRenderer.java?rev=678721&r1=678720&r2=678721&view=diff
>
> > > =========================================================================
>  > >== === ---
>  > > maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/a
>  > >pa
>
> > > che/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.j
>
> > >ava (original) +++
>
> > > maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/a
>  > >pa
>
> > > che/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.j
>
> > >ava Tue Jul 22 04:39:06 2008 @@ -90,6 +90,11 @@
>
> > >
>  > >      private static final Set JAR_SUBTYPE = new HashSet();
>  > >
>  > > +    /**
>  > > +     * An HTML script tag with the Javascript used by the dependencies
>  > > report. +     */
>  > > +    private static final String JAVASCRIPT;
>  > > +
>  > >      private final Locale locale;
>  > >
>  > >      private final DependencyNode dependencyTreeNode;
>  > > @@ -151,6 +156,26 @@
>  > >          {
>  > >              throw new RuntimeException( e );
>  > >          }
>  > > +
>  > > +        StringBuffer sb = new StringBuffer();
>  > > +        sb.append( "<script language=\"javascript\"
>  > > type=\"text/javascript\">" ).append( "\n" ); +        sb.append( "
>  > > function toggleDependencyDetail( divId, imgId )" ).append( "\n" ); +
>  > > sb.append( "      {" ).append( "\n" );
>  > > +        sb.append( "        var div = document.getElementById( divId );"
>  > > ).append( "\n" ); +        sb.append( "        var img =
>  > > document.getElementById( imgId );" ).append( "\n" ); +        sb.append(
>  > > " if( div.style.display == '' )" ).append( "\n" ); +        sb.append( "
>  > >       {" ).append( "\n" );
>  > > +        sb.append( "          div.style.display = 'none';" ).append(
>  > > "\n" ); +        sb.append( "          img.src='" + IMG_INFO_URL + "';"
>  > > ).append( "\n" ); +        sb.append( "        }" ).append( "\n" ); +
>  > >    sb.append( "        else" ).append( "\n" );
>  > > +        sb.append( "        {" ).append( "\n" );
>  > > +        sb.append( "          div.style.display = '';" ).append( "\n" );
>  > > +        sb.append( "          img.src='" + IMG_CLOSE_URL + "';"
>  > > ).append( "\n" ); +        sb.append( "        }" ).append( "\n" );
>  > > +        sb.append( "      }" ).append( "\n" );
>  > > +        sb.append( "</script>" ).append( "\n" );
>  > > +        JAVASCRIPT = sb.toString();
>  > >      }
>  > >
>  > >      /**
>  > > @@ -1266,28 +1291,6 @@
>  > >      }
>  > >
>  > >      /**
>  > > -     * an HTML script tag with the Javascript used by the dependencies
>  > > report. -     */
>  > > -    private static final String JAVASCRIPT =
>  > > -        "<script language=\"javascript\" type=\"text/javascript\">\n" +
>  > > -        "      function toggleDependencyDetail( divId, imgId )\n" +
>  > > -        "      {\n" +
>  > > -        "        var div = document.getElementById( divId );\n" +
>  > > -        "        var img = document.getElementById( imgId );\n" +
>  > > -        "        if( div.style.display == '' )\n" +
>  > > -        "        {\n" +
>  > > -        "          div.style.display = 'none';\n"+
>  > > -        "          img.src='" + IMG_INFO_URL + "';\n" +
>  > > -        "        }\n" +
>  > > -        "        else\n" +
>  > > -        "        {\n" +
>  > > -        "          div.style.display = '';\n" +
>  > > -        "          img.src='" + IMG_CLOSE_URL + "';\n" +
>  > > -        "        }\n" +
>  > > -        "      }\n" +
>  > > -        "</script>\n";
>  > > -
>  > > -    /**
>  > >       * @return a valid HTML ID respecting
>  > >       * <a href="http://www.w3.org/TR/xhtml1/#C_8";>XHTML 1.0 section C.8.
>  > > Fragment Identifiers</a> */
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: [EMAIL PROTECTED]
>  > For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to