jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Milamber <milam...@apache.org>
Subject Re: svn commit: r1698206 - in /jmeter/trunk/src: components/org/apache/jmeter/visualizers/ functions/org/apache/jmeter/functions/ jorphan/org/apache/commons/cli/avalon/ junit/org/apache/jmeter/protocol/java/control/gui/ protocol/http/org/apache/jmeter/prot...
Date Thu, 27 Aug 2015 19:07:35 GMT


On 27/08/2015 19:40, fschumacher@apache.org wrote:
> Author: fschumacher
> Date: Thu Aug 27 18:40:51 2015
> New Revision: 1698206
>
> URL: http://svn.apache.org/r1698206
> Log:
> Replace old style for loops. Patch contributed Graham Russell.

Please note that this commit includes some code formatting and one 
variable renaming (varnames => varNames)
Probably, the message commit could have been more comprehensive.


>
> Bugzilla Id: 57981
>
> Modified:
>      jmeter/trunk/src/components/org/apache/jmeter/visualizers/AxisGraph.java
>      jmeter/trunk/src/functions/org/apache/jmeter/functions/CharFunction.java
>      jmeter/trunk/src/jorphan/org/apache/commons/cli/avalon/CLArgsParser.java
>      jmeter/trunk/src/junit/org/apache/jmeter/protocol/java/control/gui/ClassFilter.java
>      jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AjpSampler.java
>      jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
>
> Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/AxisGraph.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/AxisGraph.java?rev=1698206&r1=1698205&r2=1698206&view=diff
> ==============================================================================
> --- jmeter/trunk/src/components/org/apache/jmeter/visualizers/AxisGraph.java (original)
> +++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/AxisGraph.java Thu Aug
27 18:40:51 2015
> @@ -316,12 +316,11 @@ public class AxisGraph extends JPanel {
>       }
>   
>       private double findMax(double _data[][]) {
> -        double max = 0;
> -        max = _data[0][0];
> -        for (int i = 0; i < _data.length; i++) {
> -            for (int j = 0; j < _data[i].length; j++) {
> -                if (_data[i][j] > max) {
> -                    max = _data[i][j];
> +        double max = _data[0][0];
> +        for (double[] dArray : _data) {
> +            for (double d : dArray) {
> +                if (d > max) {
> +                    max = d;
>                   }
>               }
>           }
>
> Modified: jmeter/trunk/src/functions/org/apache/jmeter/functions/CharFunction.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/functions/org/apache/jmeter/functions/CharFunction.java?rev=1698206&r1=1698205&r2=1698206&view=diff
> ==============================================================================
> --- jmeter/trunk/src/functions/org/apache/jmeter/functions/CharFunction.java (original)
> +++ jmeter/trunk/src/functions/org/apache/jmeter/functions/CharFunction.java Thu Aug
27 18:40:51 2015
> @@ -56,14 +56,14 @@ public class CharFunction extends Abstra
>               throws InvalidVariableException {
>   
>           StringBuilder sb = new StringBuilder(values.length);
> -        for (int i=0; i < values.length; i++){
> -            String numberString = ((CompoundVariable) values[i]).execute().trim();
> +        for (Object val : values) {
> +            String numberString = ((CompoundVariable) val).execute().trim();
>               try {
> -                long value=Long.decode(numberString).longValue();
> +                long value = Long.decode(numberString).longValue();
>                   char ch = (char) value;
>                   sb.append(ch);
> -            } catch (NumberFormatException e){
> -                log.warn("Could not parse "+numberString+" : "+e);
> +            } catch (NumberFormatException e) {
> +                log.warn("Could not parse " + numberString + " : " + e);
>               }
>           }
>           return sb.toString();
>
> Modified: jmeter/trunk/src/jorphan/org/apache/commons/cli/avalon/CLArgsParser.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/commons/cli/avalon/CLArgsParser.java?rev=1698206&r1=1698205&r2=1698206&view=diff
> ==============================================================================
> --- jmeter/trunk/src/jorphan/org/apache/commons/cli/avalon/CLArgsParser.java (original)
> +++ jmeter/trunk/src/jorphan/org/apache/commons/cli/avalon/CLArgsParser.java Thu Aug
27 18:40:51 2015
> @@ -153,9 +153,9 @@ public final class CLArgsParser {
>        * @return the descriptor
>        */
>       private final CLOptionDescriptor getDescriptorFor(final int id) {
> -        for (int i = 0; i < m_optionDescriptors.length; i++) {
> -            if (m_optionDescriptors[i].getId() == id) {
> -                return m_optionDescriptors[i];
> +        for (CLOptionDescriptor optionDescriptor : m_optionDescriptors) {
> +            if (optionDescriptor.getId() == id) {
> +                return optionDescriptor;
>               }
>           }
>   
> @@ -170,9 +170,9 @@ public final class CLArgsParser {
>        * @return the descriptor
>        */
>       private final CLOptionDescriptor getDescriptorFor(final String name) {
> -        for (int i = 0; i < m_optionDescriptors.length; i++) {
> -            if (m_optionDescriptors[i].getName().equals(name)) {
> -                return m_optionDescriptors[i];
> +        for (CLOptionDescriptor optionDescriptor : m_optionDescriptors) {
> +            if (optionDescriptor.getName().equals(name)) {
> +                return optionDescriptor;
>               }
>           }
>   
> @@ -277,8 +277,8 @@ public final class CLArgsParser {
>               final CLOption option = arguments.elementAt(i);
>               final int id = option.getDescriptor().getId();
>   
> -            for (int j = 0; j < incompatible.length; j++) {
> -                if (id == incompatible[j]) {
> +            for (int anIncompatible : incompatible) {
> +                if (id == anIncompatible) {
>                       final CLOption originalOption = arguments.elementAt(original);
>                       final int originalId = originalOption.getDescriptor().getId();
>   
> @@ -495,8 +495,8 @@ public final class CLArgsParser {
>       }
>   
>       private final boolean isSeparator(final char ch, final char[] separators) {
> -        for (int i = 0; i < separators.length; i++) {
> -            if (ch == separators[i]) {
> +        for (char separator : separators) {
> +            if (ch == separator) {
>                   return true;
>               }
>           }
> @@ -668,8 +668,7 @@ public final class CLArgsParser {
>           final int size = m_options.size();
>           m_optionIndex = new Hashtable<>(size * 2);
>   
> -        for (int i = 0; i < size; i++) {
> -            final CLOption option = m_options.get(i);
> +        for (final CLOption option : m_options) {
>               final CLOptionDescriptor optionDescriptor = getDescriptorFor(option.getDescriptor().getId());
>   
>               m_optionIndex.put(Integer.valueOf(option.getDescriptor().getId()), option);
>
> Modified: jmeter/trunk/src/junit/org/apache/jmeter/protocol/java/control/gui/ClassFilter.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/junit/org/apache/jmeter/protocol/java/control/gui/ClassFilter.java?rev=1698206&r1=1698205&r2=1698206&view=diff
> ==============================================================================
> --- jmeter/trunk/src/junit/org/apache/jmeter/protocol/java/control/gui/ClassFilter.java
(original)
> +++ jmeter/trunk/src/junit/org/apache/jmeter/protocol/java/control/gui/ClassFilter.java
Thu Aug 27 18:40:51 2015
> @@ -36,14 +36,12 @@ class ClassFilter {
>   
>       private boolean include(String text) {
>           if (pkgs.length == 0) return true; // i.e. no filter
> -        boolean inc = false;
> -        for (int idx=0; idx < pkgs.length; idx++) {
> -            if (text.startsWith(pkgs[idx])){
> -                inc = true;
> -                break;
> +        for (String pkg : pkgs) {
> +            if (text.startsWith(pkg)) {
> +                return true;
>               }
>           }
> -        return inc;
> +        return false;
>       }
>   
>       String[] filterArray(List<String> items) {
>
> Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AjpSampler.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AjpSampler.java?rev=1698206&r1=1698205&r2=1698206&view=diff
> ==============================================================================
> --- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AjpSampler.java
(original)
> +++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AjpSampler.java
Thu Aug 27 18:40:51 2015
> @@ -316,15 +316,12 @@ public class AjpSampler extends HTTPSamp
>       private String encode(String value)  {
>           StringBuilder newValue = new StringBuilder();
>           char[] chars = value.toCharArray();
> -        for (int i = 0; i < chars.length; i++)
> -        {
> -            if (chars[i] == '\\')//$NON-NLS-1$
> +        for (char c : chars) {
> +            if (c == '\\')//$NON-NLS-1$
>               {
>                   newValue.append("\\\\");//$NON-NLS-1$
> -            }
> -            else
> -            {
> -                newValue.append(chars[i]);
> +            } else {
> +                newValue.append(c);
>               }
>           }
>           return newValue.toString();
>
> Modified: jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java?rev=1698206&r1=1698205&r2=1698206&view=diff
> ==============================================================================
> --- jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
(original)
> +++ jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
Thu Aug 27 18:40:51 2015
> @@ -85,11 +85,11 @@ public abstract class AbstractJDBCTestEl
>   
>           //Get all fields in java.sql.Types and store the corresponding int values
>           Field[] fields = java.sql.Types.class.getFields();
> -        for (int i=0; i<fields.length; i++) {
> +        for (Field field : fields) {
>               try {
> -                String name = fields[i].getName();
> -                Integer value = (Integer)fields[i].get(null);
> -                mapJdbcNameToInt.put(name.toLowerCase(java.util.Locale.ENGLISH),value);
> +                String name = field.getName();
> +                Integer value = (Integer) field.get(null);
> +                mapJdbcNameToInt.put(name.toLowerCase(java.util.Locale.ENGLISH), value);
>               } catch (IllegalAccessException e) {
>                   throw new RuntimeException(e); // should not happen
>               }
> @@ -431,7 +431,7 @@ public abstract class AbstractJDBCTestEl
>           
>   
>           JMeterVariables jmvars = getThreadContext().getVariables();
> -        String varnames[] = getVariableNames().split(COMMA);
> +        String varNames[] = getVariableNames().split(COMMA);
>           String resultVariable = getResultVariable().trim();
>           List<Map<String, Object> > results = null;
>           if(resultVariable.length() > 0) {
> @@ -460,8 +460,8 @@ public abstract class AbstractJDBCTestEl
>                   } else {
>                       sb.append('\t');
>                   }
> -                if (i <= varnames.length) { // i starts at 1
> -                    String name = varnames[i - 1].trim();
> +                if (i <= varNames.length) { // i starts at 1
> +                    String name = varNames[i - 1].trim();
>                       if (name.length()>0){ // Save the value in the variable if present
>                           jmvars.put(name+UNDERSCORE+j, o == null ? null : o.toString());
>                       }
> @@ -469,16 +469,16 @@ public abstract class AbstractJDBCTestEl
>               }
>           }
>           // Remove any additional values from previous sample
> -        for(int i=0; i < varnames.length; i++){
> -            String name = varnames[i].trim();
> -            if (name.length()>0 && jmvars != null){
> -                final String varCount = name+"_#"; // $NON-NLS-1$
> +        for (String varName : varNames) {
> +            String name = varName.trim();
> +            if (name.length() > 0 && jmvars != null) {
> +                final String varCount = name + "_#"; // $NON-NLS-1$
>                   // Get the previous count
>                   String prevCount = jmvars.get(varCount);
> -                if (prevCount != null){
> +                if (prevCount != null) {
>                       int prev = Integer.parseInt(prevCount);
> -                    for (int n=j+1; n <= prev; n++ ){
> -                        jmvars.remove(name+UNDERSCORE+n);
> +                    for (int n = j + 1; n <= prev; n++) {
> +                        jmvars.remove(name + UNDERSCORE + n);
>                       }
>                   }
>                   jmvars.put(varCount, Integer.toString(j)); // save the current count
>
>
>


Mime
View raw message