You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by sy...@apache.org on 2004/11/12 14:35:27 UTC

svn commit: rev 57516 - cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel

Author: sylvain
Date: Fri Nov 12 05:35:27 2004
New Revision: 57516

Modified:
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java
Log:
Optimize lazy parsing of value. Tim, I think we finally got it :-)


Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java	Fri Nov 12 05:35:27 2004
@@ -201,14 +201,18 @@
         // Only convert if the text value actually changed. Otherwise, keep the old value
         // and/or the old validation error (allows to keep errors when clicking on actions)
         if (!(newEnteredValue == null ? "" : newEnteredValue).equals((enteredValue == null ? "" : enteredValue))) {
-            // Make sure the old value has been parsed and validated.
-            Object oldValue = getValue();
+            
+            // If we have some value-changed listeners, we must make sure the current value has been
+            // parsed, to fill the event. Otherwise, we don't need to spend that extra CPU time.
+            boolean hasListeners = hasValueChangedListeners();
+            Object oldValue = hasListeners ? getValue() : null;
+            
             enteredValue = newEnteredValue;
             validationError = null;
             value = null;
             this.valueState = VALUE_UNPARSED;
 
-            if (hasValueChangedListeners()) {
+            if (hasListeners) {
                 // Throw an event that will hold the old value and
                 // will lazily compute the new value only if needed.
                 getForm().addWidgetEvent(new DeferredValueChangedEvent(this, oldValue));

Re: svn commit: rev 57516 - cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel

Posted by Tim Larson <ti...@keow.org>.
On Fri, Nov 12, 2004 at 01:35:27PM -0000, sylvain@apache.org wrote:
> Author: sylvain
> Date: Fri Nov 12 05:35:27 2004
> New Revision: 57516
> 
> Modified:
>    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java
> Log:
> Optimize lazy parsing of value. Tim, I think we finally got it :-)

Thanks :)

--Tim Larson