You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by "Felix Scheffer (JIRA)" <ji...@apache.org> on 2014/08/12 22:16:12 UTC

[jira] [Updated] (TAP5-2374) Unnecessary boolean condition

     [ https://issues.apache.org/jira/browse/TAP5-2374?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Scheffer updated TAP5-2374:
---------------------------------

    Attachment: 0002-TAP5-2374-Unnecessary-boolean-condition.patch

patch...

> Unnecessary boolean condition
> -----------------------------
>
>                 Key: TAP5-2374
>                 URL: https://issues.apache.org/jira/browse/TAP5-2374
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.4
>            Reporter: Muhammad Gelbana
>            Priority: Trivial
>         Attachments: 0002-TAP5-2374-Unnecessary-boolean-condition.patch
>
>
> The Zone component's beginRender event handler method has 2 successive unnecessary boolean conditions:
> {code:java}
>     void beginRender(MarkupWriter writer)
>     {
>         clientId = resources.isBound("id") ? idParameter : javascriptSupport.allocateClientId(resources);
>         Element e = writer.element(elementName,
>                 "id", clientId,
>                 "data-container-type", "zone");
>         resources.renderInformalParameters(writer);
>         insideForm = formSupport != null;
>         if (insideForm) // <<<<<<<<<<<<<<<<<<<<
>         {
>             JSONObject parameters = new JSONObject(RequestConstants.FORM_CLIENTID_PARAMETER, formSupport.getClientId(),
>                     RequestConstants.FORM_COMPONENTID_PARAMETER, formSupport.getFormComponentId());
>             e.attribute("data-zone-parameters",
>                     parameters.toString(compactJSON));
>         }
>         if (insideForm) // <<<<<<<<<<<<<<<<<<<<
>         {
>             hiddenFieldPositioner = new HiddenFieldPositioner(writer, rules);
>             actionSink = new ComponentActionSink(logger, clientDataEncoder);
>             environment.push(FormSupport.class, new FormSupportAdapter(formSupport)
>             {
>                 @Override
>                 public <T> void store(T component, ComponentAction<T> action)
>                 {
>                     actionSink.store(component, action);
>                 }
>                 @Override
>                 public <T> void storeCancel(T component, ComponentAction<T> action)
>                 {
>                     actionSink.storeCancel(component, action);
>                 }
>                 @Override
>                 public <T> void storeAndExecute(T component, ComponentAction<T> action)
>                 {
>                     store(component, action);
>                     action.execute(component);
>                 }
>             });
>         }
>         heartbeat.begin();
>     }
> {code}
> These 2 blocks could have been merged instead of having to check the boolean value twice



--
This message was sent by Atlassian JIRA
(v6.2#6252)