struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hus...@apache.org
Subject svn commit: r591174 - in /struts/struts2/trunk/core/src/main/java/org/apache/struts2: components/ config/ dispatcher/ interceptor/ interceptor/debugging/ util/ views/xslt/
Date Fri, 02 Nov 2007 00:31:56 GMT
Author: husted
Date: Thu Nov  1 17:31:53 2007
New Revision: 591174

URL: http://svn.apache.org/viewvc?rev=591174&view=rev
Log:
WW-2282 Apply a number of "FindBugs" performance optimizations submitted by Giovanni Azua
Garcia. Most (or all) of these are line for line substitutions. 

Modified:
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Date.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Debug.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/DoubleListUIBean.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ListUIBean.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/UIBean.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/MethodConfigurationProvider.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ApplicationMap.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/RequestMap.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ScopeInterceptor.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/Counter.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/IteratorFilterSupport.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/xslt/MapAdapter.java

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Date.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Date.java?rev=591174&r1=591173&r2=591174&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Date.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Date.java Thu Nov
 1 17:31:53 2007
@@ -231,31 +231,31 @@
         int years = days / 365;
 
         if (years > 0) {
-            args.add(new Long(years));
-            args.add(new Long(day));
+            args.add(Long.valueOf(years));
+            args.add(Long.valueOf(day));
             args.add(sb);
             args.add(null);
             sb.append(tp.getText(DATETAG_PROPERTY_YEARS, DATETAG_DEFAULT_YEARS, args));
         } else if (day > 0) {
-            args.add(new Long(day));
-            args.add(new Long(hour));
+            args.add(Long.valueOf(day));
+            args.add(Long.valueOf(hour));
             args.add(sb);
             args.add(null);
             sb.append(tp.getText(DATETAG_PROPERTY_DAYS, DATETAG_DEFAULT_DAYS, args));
         } else if (hour > 0) {
-            args.add(new Long(hour));
-            args.add(new Long(min));
+            args.add(Long.valueOf(hour));
+            args.add(Long.valueOf(min));
             args.add(sb);
             args.add(null);
             sb.append(tp.getText(DATETAG_PROPERTY_HOURS, DATETAG_DEFAULT_HOURS, args));
         } else if (min > 0) {
-            args.add(new Long(min));
-            args.add(new Long(sec));
+            args.add(Long.valueOf(min));
+            args.add(Long.valueOf(sec));
             args.add(sb);
             args.add(null);
             sb.append(tp.getText(DATETAG_PROPERTY_MINUTES, DATETAG_DEFAULT_MINUTES, args));
         } else {
-            args.add(new Long(sec));
+            args.add(Long.valueOf(sec));
             args.add(sb);
             args.add(null);
             sb.append(tp.getText(DATETAG_PROPERTY_SECONDS, DATETAG_DEFAULT_SECONDS, args));

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Debug.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Debug.java?rev=591174&r1=591173&r2=591174&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Debug.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Debug.java Thu Nov
 1 17:31:53 2007
@@ -79,7 +79,7 @@
         return result;
     }
 
-    private class DebugMapEntry implements Map.Entry {
+    private static class DebugMapEntry implements Map.Entry {
         private Object key;
         private Object value;
 

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/DoubleListUIBean.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/DoubleListUIBean.java?rev=591174&r1=591173&r2=591174&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/DoubleListUIBean.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/DoubleListUIBean.java
Thu Nov  1 17:31:53 2007
@@ -172,13 +172,13 @@
             if (doubleValue != null) {
                 addParameter("doubleNameValue", findValue(doubleValue, valueClazz));
             } else if (doubleName != null) {
-                addParameter("doubleNameValue", findValue(doubleName.toString(), valueClazz));
+                addParameter("doubleNameValue", findValue(doubleName, valueClazz));
             }
         } else {
             if (doubleValue != null) {
                 addParameter("doubleNameValue", findValue(doubleValue));
             } else if (doubleName != null) {
-                addParameter("doubleNameValue", findValue(doubleName.toString()));
+                addParameter("doubleNameValue", findValue(doubleName));
             }
         }
 

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ListUIBean.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ListUIBean.java?rev=591174&r1=591173&r2=591174&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ListUIBean.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ListUIBean.java
Thu Nov  1 17:31:53 2007
@@ -94,11 +94,11 @@
         }
 
         if (value instanceof Collection) {
-            addParameter("listSize", new Integer(((Collection) value).size()));
+            addParameter("listSize", Integer.valueOf(((Collection) value).size()));
         } else if (value instanceof Map) {
-            addParameter("listSize", new Integer(((Map) value).size()));
+            addParameter("listSize", Integer.valueOf(((Map) value).size()));
         } else if (value != null && value.getClass().isArray()) {
-            addParameter("listSize", new Integer(Array.getLength(value)));
+            addParameter("listSize", Integer.valueOf(Array.getLength(value)));
         }
 
         if (listKey != null) {

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/UIBean.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/UIBean.java?rev=591174&r1=591173&r2=591174&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/UIBean.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/UIBean.java Thu
Nov  1 17:31:53 2007
@@ -887,7 +887,7 @@
                 String value = null;
                 if (configEntry.length > 1) {
                     value = configEntry[1].trim();
-                    tooltipConfig.put(key, value.toString());
+                    tooltipConfig.put(key, value);
                 }
                 else {
                     LOG.warn("component "+component+" tooltip config param "+key+" has no
value defined, skipped");

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java?rev=591174&r1=591173&r2=591174&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java
Thu Nov  1 17:31:53 2007
@@ -285,7 +285,7 @@
         }
     }
     
-    class ObjectFactoryDelegateFactory implements Factory {
+    static class ObjectFactoryDelegateFactory implements Factory {
         String name;
         Class type;
         ObjectFactoryDelegateFactory(String name, Class type) {

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/MethodConfigurationProvider.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/MethodConfigurationProvider.java?rev=591174&r1=591173&r2=591174&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/MethodConfigurationProvider.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/MethodConfigurationProvider.java
Thu Nov  1 17:31:53 2007
@@ -112,11 +112,11 @@
 
         boolean added = false;
         for (Object namespace : namespaces) {
-            Map actions = (Map) allActionConfigs.get(namespace);
-            Set actionNames = actions.keySet();
-            for (Object actionName : actionNames) {
-                ActionConfig actionConfig = (ActionConfig) actions.get(actionName);
-                added = added | addDynamicMethods(actions, (String) actionName, actionConfig);
+            Map<Object, Object> actions = (Map) allActionConfigs.get(namespace);
+            for (Map.Entry<Object, Object> actionEntry : actions.entrySet()) {
+                String actionName = (String) actionEntry.getKey();
+                ActionConfig actionConfig = (ActionConfig) actionEntry.getValue();
+                added = added | addDynamicMethods(actions, actionName, actionConfig);
             }
         }
 

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java?rev=591174&r1=591173&r2=591174&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
Thu Nov  1 17:31:53 2007
@@ -85,10 +85,10 @@
             try {
                 Integer count = (Integer)request.getAttribute(COUNTER);
                 if (count == null) {
-                    count = new Integer(1);
+                    count = Integer.valueOf(1);
                 }
                 else {
-                    count = new Integer(count.intValue()+1);
+                    count = Integer.valueOf(count.intValue()+1);
                 }
                 request.setAttribute(COUNTER, count);
 
@@ -98,7 +98,7 @@
             } finally {
                 int counterVal = ((Integer)request.getAttribute(COUNTER)).intValue();
                 counterVal -= 1;
-                request.setAttribute(COUNTER, new Integer(counterVal));
+                request.setAttribute(COUNTER, Integer.valueOf(counterVal));
                 cleanUp(request);
             }
         }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ApplicationMap.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ApplicationMap.java?rev=591174&r1=591173&r2=591174&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ApplicationMap.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ApplicationMap.java
Thu Nov  1 17:31:53 2007
@@ -103,7 +103,7 @@
                     }
 
                     public Object setValue(Object obj) {
-                        context.setAttribute(key.toString(), obj);
+                        context.setAttribute(key, obj);
 
                         return value;
                     }
@@ -136,7 +136,7 @@
                     }
 
                     public Object setValue(Object obj) {
-                        context.setAttribute(key.toString(), obj);
+                        context.setAttribute(key, obj);
 
                         return value;
                     }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java?rev=591174&r1=591173&r2=591174&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
Thu Nov  1 17:31:53 2007
@@ -745,7 +745,7 @@
     /**
      * Provide an accessor class for static XWork utility.
      */
-    public class Locator {
+    public static class Locator {
         public Location getLocation(Object obj) {
             Location loc = LocationUtils.getLocation(obj);
             if (loc == null) {

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/RequestMap.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/RequestMap.java?rev=591174&r1=591173&r2=591174&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/RequestMap.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/RequestMap.java
Thu Nov  1 17:31:53 2007
@@ -97,7 +97,7 @@
                     }
 
                     public Object setValue(Object obj) {
-                        request.setAttribute(key.toString(), obj);
+                        request.setAttribute(key, obj);
 
                         return value;
                     }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java?rev=591174&r1=591173&r2=591174&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java
Thu Nov  1 17:31:53 2007
@@ -134,7 +134,7 @@
                         }
 
                         public Object setValue(Object obj) {
-                            session.setAttribute(key.toString(), obj);
+                            session.setAttribute(key, obj);
 
                             return value;
                         }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ScopeInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ScopeInterceptor.java?rev=591174&r1=591173&r2=591174&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ScopeInterceptor.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ScopeInterceptor.java
Thu Nov  1 17:31:53 2007
@@ -180,7 +180,7 @@
      */
     public void setAutoCreateSession(String value) {
         if (value != null && value.length() > 0) {
-            this.autoCreateSession = new Boolean(value).booleanValue();
+            this.autoCreateSession = Boolean.valueOf(value).booleanValue();
         }
     }
 

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java?rev=591174&r1=591173&r2=591174&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
Thu Nov  1 17:31:53 2007
@@ -393,12 +393,12 @@
             }
         } else if (bean instanceof Map) {
 
-            Map map = (Map) bean;
+            Map<Object, Object> map = (Map) bean;
 
             // Loop through keys and call ourselves
-            for (Object key : map.keySet()) {
-                Object Objvalue = map.get(key);
-                serializeIt(Objvalue, key.toString(), writer, stack);
+            for (Map.Entry<Object, Object> entry : map.entrySet()) {
+                Object objValue = entry.getValue();
+                serializeIt(objValue, entry.getKey().toString(), writer, stack);
             }
         } else if (bean.getClass().isArray()) {
             // It's an array, loop through it and keep calling ourselves
@@ -448,4 +448,5 @@
 
 
 }
+
 

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/Counter.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/Counter.java?rev=591174&r1=591173&r2=591174&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/Counter.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/Counter.java Thu Nov 
1 17:31:53 2007
@@ -114,7 +114,7 @@
     }
 
     public Object next() {
-        return new Long(getNext());
+        return Long.valueOf(getNext());
     }
 
     public void remove() {

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/IteratorFilterSupport.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/IteratorFilterSupport.java?rev=591174&r1=591173&r2=591174&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/IteratorFilterSupport.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/IteratorFilterSupport.java
Thu Nov  1 17:31:53 2007
@@ -37,7 +37,7 @@
 
 
     // Wrapper for enumerations
-    public class EnumerationIterator implements Iterator {
+    public static class EnumerationIterator implements Iterator {
         Enumeration enumeration;
 
         public EnumerationIterator(Enumeration aEnum) {

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/xslt/MapAdapter.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/xslt/MapAdapter.java?rev=591174&r1=591173&r2=591174&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/xslt/MapAdapter.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/xslt/MapAdapter.java
Thu Nov  1 17:31:53 2007
@@ -66,7 +66,7 @@
         return children;
     }
 
-    class EntryElement extends AbstractAdapterElement {
+    static class EntryElement extends AbstractAdapterElement {
         Object key, value;
 
         public EntryElement(  AdapterFactory adapterFactory,



Mime
View raw message