Author: bayard
Date: Sat Jul  3 19:34:40 2010
New Revision: 960259

URL: http://svn.apache.org/viewvc?rev=960259&view=rev
Log:
Improving the performance of SetSupport by only calling bodyContent.getString() 
once per Jeremy's patch #49547

Modified:
    
tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/SetSupport.java
    
tomcat/taglibs/standard/trunk/impl/src/test/java/org/apache/taglibs/standard/tag/common/core/TestSetSupport.java

Modified: 
tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/SetSupport.java
URL: 
http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/SetSupport.java?rev=960259&r1=960258&r2=960259&view=diff
==============================================================================
--- 
tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/SetSupport.java
 (original)
+++ 
tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/SetSupport.java
 Sat Jul  3 19:34:40 2010
@@ -44,6 +44,11 @@ import org.apache.taglibs.standard.resou
 /**
  * <p>Support for handlers of the &lt;set&gt; tag.</p>
  *
+ * <p>The protected <code>value</code> and <code>valueSpecified</code>
+ * attributes must be set in sync. That is, if you set the value then 
+ * you should set <code>valueSpecified</code> to <code>true<code>, if you 
unset the value, then 
+ * you should set <code>valueSpecified</code> to <code>false<code>. </p>
+ *
  * @author Shawn Bayern
  */
 public class SetSupport extends BodyTagSupport {
@@ -183,24 +188,18 @@ public class SetSupport extends BodyTagS
     }
     
     Object getResult() {
-        Object result;      // what we'll store in scope:var
-
-        // determine the value by...
-        if (value != null) {
-            // ... reading our attribute
-            result = value;
-        } else if (valueSpecified) {
-            // ... accepting an explicit null
-            result = null;
+        if (valueSpecified) {
+            return value;
+        } else if (bodyContent == null) {
+            return "";
         } else {
-            // ... retrieving and trimming our body
-            if (bodyContent == null || bodyContent.getString() == null)
-                result = "";
-            else
-                result = bodyContent.getString().trim();
+            String content = bodyContent.getString();
+            if (content == null) {
+                return "";
+            } else {
+                return content.trim();
+            }
         }
-
-        return result;
     }
     
     /**

Modified: 
tomcat/taglibs/standard/trunk/impl/src/test/java/org/apache/taglibs/standard/tag/common/core/TestSetSupport.java
URL: 
http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/impl/src/test/java/org/apache/taglibs/standard/tag/common/core/TestSetSupport.java?rev=960259&r1=960258&r2=960259&view=diff
==============================================================================
--- 
tomcat/taglibs/standard/trunk/impl/src/test/java/org/apache/taglibs/standard/tag/common/core/TestSetSupport.java
 (original)
+++ 
tomcat/taglibs/standard/trunk/impl/src/test/java/org/apache/taglibs/standard/tag/common/core/TestSetSupport.java
 Sat Jul  3 19:34:40 2010
@@ -62,6 +62,7 @@ public class TestSetSupport {
     @Test
     public void test49526WhenNotMapped() throws JspException {
         tag.setVar(VAR);
+        tag.valueSpecified = true;
         tag.value = VALUE;
 
         // verify mapper is checked but that no action is taken
@@ -80,6 +81,7 @@ public class TestSetSupport {
     @Test
     public void test49526WhenAlreadyMapped() throws JspException {
         tag.setVar(VAR);
+        tag.valueSpecified = true;
         tag.value = VALUE;
 
         // verify mapper is checked and the mapped variable removed
@@ -100,6 +102,7 @@ public class TestSetSupport {
     @Test
     public void test49526WhenNotUsingPageContext() throws JspException {
         tag.setVar(VAR);
+        tag.valueSpecified = true;
         tag.value = VALUE;
         tag.setScope("request");
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to