This is an automated email from the ASF dual-hosted git repository. cschneider pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/aries.git
The following commit(s) were added to refs/heads/trunk by this push: new 56a76d3 Fix the problem of using '+' and '+=' operators to concatenate strings in a loop. 56a76d3 is described below commit 56a76d3e9cf64479620482320912b254caae1462 Author: Kui LIU <brucekui...@gmail.com> AuthorDate: Mon Oct 9 22:15:04 2017 +0200 Fix the problem of using '+' and '+=' operators to concatenate strings in a loop. The method is building a String using concatenation in a loop. In each iteration, the String is converted to a StringBuilder, appended to, and converted back to a String. This can lead to a cost quadratic in the number of iterations, as the growing string is recopied in each iteration. Better performance can be obtained by using a StringBuilder explicitly. http://findbugs.sourceforge.net/bugDescriptions.html#SBSC_USE_STRINGBUFFER_CONCATENATION --- .../api/persistence/MarketSummaryDataBean.java | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/samples/ariestrader/modules/ariestrader-api/src/main/java/org/apache/aries/samples/ariestrader/api/persistence/MarketSummaryDataBean.java b/samples/ariestrader/modules/ariestrader-api/src/main/java/org/apache/aries/samples/ariestrader/api/persistence/MarketSummaryDataBean.java index 13df51e..a5fff45 100644 --- a/samples/ariestrader/modules/ariestrader-api/src/main/java/org/apache/aries/samples/ariestrader/api/persistence/MarketSummaryDataBean.java +++ b/samples/ariestrader/modules/ariestrader-api/src/main/java/org/apache/aries/samples/ariestrader/api/persistence/MarketSummaryDataBean.java @@ -62,30 +62,30 @@ public class MarketSummaryDataBean implements Serializable public String toString() { - String ret = "\n\tMarket Summary at: " + getSummaryDate() - + "\n\t\t TSIA:" + getTSIA() - + "\n\t\t openTSIA:" + getOpenTSIA() - + "\n\t\t gain:" + getGainPercent() - + "\n\t\t volume:" + getVolume() - ; + StringBuilder ret = new StringBuilder(); + ret.append("\n\tMarket Summary at: ").append(getSummaryDate()) + .append("\n\t\t TSIA:").append(getTSIA()) + .append("\n\t\t openTSIA:").append(getOpenTSIA()) + .append("\n\t\t gain:").append(getGainPercent()) + .append("\n\t\t volume:").append(getVolume()); if ( (getTopGainers()==null) || (getTopLosers()==null) ) - return ret; - ret += "\n\t\t Current Top Gainers:"; + return ret.toString(); + ret.append("\n\t\t Current Top Gainers:"); Iterator it = getTopGainers().iterator(); while ( it.hasNext() ) { QuoteDataBean quoteData = (QuoteDataBean) it.next(); - ret += ( "\n\t\t\t" + quoteData.toString() ); + ret.append("\n\t\t\t").append(quoteData.toString()); } - ret += "\n\t\t Current Top Losers:"; + ret.append("\n\t\t Current Top Losers:"); it = getTopLosers().iterator(); while ( it.hasNext() ) { QuoteDataBean quoteData = (QuoteDataBean) it.next(); - ret += ( "\n\t\t\t" + quoteData.toString() ); + ret.append("\n\t\t\t").append(quoteData.toString()); } - return ret; + return ret.toString(); } public String toHTML() {