You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Xiaoming Shi (JIRA)" <ji...@apache.org> on 2011/02/17 03:48:24 UTC

[jira] Created: (WW-3575) replace function is called multiple times, which can be done in one run

replace function is called multiple times, which can be done in one run
-----------------------------------------------------------------------

                 Key: WW-3575
                 URL: https://issues.apache.org/jira/browse/WW-3575
             Project: Struts 2
          Issue Type: New Feature
          Components: Plugin - JasperReports
    Affects Versions: 2.2.1.1
            Reporter: Xiaoming Shi


In the function "makeXmlJavaIdentifier"

(./struts-2.2.1/src/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/JspUtil.java            line: 1059)

The replace function is called 3 times, which can be done in one run with a for loop.  

               StringBuilder sb = new StringBuilder(name.length());
		for(int i = 0; i < name.length(); i++)
		{
			char c = name.charAt(i);
			if (c == '-')
				sb.append("$1");
			else if (c == '.')
				sb.append("$2");
			else if (c == ':')
				sb.append("$3");
			else
				sb.append(c);
		}
		return sb.toString();

The second method can be much faster .


-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Closed: (WW-3575) replace function is called multiple times, which can be done in one run

Posted by "Xiaoming Shi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WW-3575?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Xiaoming Shi closed WW-3575.
----------------------------

    Resolution: Not A Problem

> replace function is called multiple times, which can be done in one run
> -----------------------------------------------------------------------
>
>                 Key: WW-3575
>                 URL: https://issues.apache.org/jira/browse/WW-3575
>             Project: Struts 2
>          Issue Type: New Feature
>          Components: Plugin - JasperReports
>    Affects Versions: 2.2.1.1
>            Reporter: Xiaoming Shi
>
> In the function "makeXmlJavaIdentifier"
> (./struts-2.2.1/src/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/JspUtil.java            line: 1059)
> The replace function is called 3 times, which can be done in one run with a for loop.  
>                StringBuilder sb = new StringBuilder(name.length());
> 		for(int i = 0; i < name.length(); i++)
> 		{
> 			char c = name.charAt(i);
> 			if (c == '-')
> 				sb.append("$1");
> 			else if (c == '.')
> 				sb.append("$2");
> 			else if (c == ':')
> 				sb.append("$3");
> 			else
> 				sb.append(c);
> 		}
> 		return sb.toString();
> The second method can be much faster .

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira