minor #19574 [TwigBundle] Add a check for choice's attributes emptiness before calling block('attributes') (Evgeniy Tetenchuk, johnatannvmd)

This PR was merged into the 2.7 branch.

Discussion
----------

[TwigBundle] Add a check for choice's attributes emptiness before calling block('attributes')

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| License       | MIT

Remove unnecessary block calling for choices without "choice_attr" option. This check gain the performance on a large datasets.

Previous Pull to master #19527

Commits
-------

bf6748d Move space from the before 'if' to the after 'if'
d1cf4d1 [TwigBundle] Add a check for choice's attributes emptiness before calling block('attributes')
This commit is contained in:
Fabien Potencier 2016-08-17 10:53:54 -07:00
commit f12d2b75f3
1 changed files with 1 additions and 2 deletions

View File

@ -79,8 +79,7 @@
{{- block('choice_widget_options') -}}
</optgroup>
{%- else -%}
{% set attr = choice.attr %}
<option value="{{ choice.value }}" {{ block('attributes') }}{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ choice_translation_domain is same as(false) ? choice.label : choice.label|trans({}, choice_translation_domain) }}</option>
<option value="{{ choice.value }}"{% if choice.attr %} {% set attr = choice.attr %}{{ block('attributes') }}{% endif %}{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ choice_translation_domain is same as(false) ? choice.label : choice.label|trans({}, choice_translation_domain) }}</option>
{%- endif -%}
{% endfor %}
{%- endblock choice_widget_options -%}