[Django] #28907: Exploit that iterating over empty sequences is noop

14 views
Skip to first unread message

Django

unread,
Dec 7, 2017, 9:13:57 AM12/7/17
to django-...@googlegroups.com
#28907: Exploit that iterating over empty sequences is noop
------------------------------------------------+------------------------
Reporter: Дилян Палаузов | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Uncategorized | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
.. and don't check if a sequence is empty, before looping over it

--
Ticket URL: <https://code.djangoproject.com/ticket/28907>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 7, 2017, 9:14:31 AM12/7/17
to django-...@googlegroups.com
#28907: Exploit that iterating over empty sequences is noop
-------------------------------------+-------------------------------------

Reporter: Дилян Палаузов | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Uncategorized | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Дилян Палаузов):

* Attachment "less_ifs.patch" added.

Django

unread,
Dec 7, 2017, 9:35:42 AM12/7/17
to django-...@googlegroups.com
#28907: Exploit that iterating over empty sequences is noop
-------------------------------------+-------------------------------------

Reporter: Дилян Палаузов | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Uncategorized | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Jaap Roes):

This would be easier to review if it was a pull request.

In the patch I see at least one case where the `if` condition should not
be eliminated because it also needs to catch `None` values.

--
Ticket URL: <https://code.djangoproject.com/ticket/28907#comment:1>

Django

unread,
Dec 7, 2017, 12:52:37 PM12/7/17
to django-...@googlegroups.com
#28907: Exploit that iterating over empty sequences is noop
-------------------------------------+-------------------------------------

Reporter: Дилян Палаузов | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* component: Uncategorized => Core (Other)
* stage: Unreviewed => Ready for checkin


Comment:

[https://github.com/django/django/pull/9445 PR]. I removed the test
changes from the patch as those don't work as Jaap mentioned.

--
Ticket URL: <https://code.djangoproject.com/ticket/28907#comment:2>

Django

unread,
Dec 7, 2017, 5:12:33 PM12/7/17
to django-...@googlegroups.com
#28907: Exploit that iterating over empty sequences is noop
-------------------------------------+-------------------------------------

Reporter: Дилян Палаузов | Owner: nobody
Type: | Status: closed

Cleanup/optimization |
Component: Core (Other) | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"02d9419fe34eaa4d41d8a8df93373f286a36a2ae" 02d9419f]:
{{{
#!CommitTicketReference repository=""
revision="02d9419fe34eaa4d41d8a8df93373f286a36a2ae"
Fixed #28907 -- Removed unnecessary if statements.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28907#comment:3>

Django

unread,
Dec 8, 2017, 6:45:27 AM12/8/17
to django-...@googlegroups.com
#28907: Exploit that iterating over empty sequences is noop
-------------------------------------+-------------------------------------

Reporter: Дилян Палаузов | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Core (Other) | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Дилян Палаузов):

Indeed, I have not thought on the cases, where the {{{if value:}}} can be
{{{None}}}.

--
Ticket URL: <https://code.djangoproject.com/ticket/28907#comment:4>

Reply all
Reply to author
Forward
0 new messages