Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#24221 closed Cleanup/optimization (fixed)

Use compiled regular expression when checking success_url

Reported by: Tomáš Ehrlich Owned by: Tomáš Ehrlich
Component: Generic views Version: 1.8alpha1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

While working on #24220 I also noticed that old-style formatting is checked using re.search with inline regexp. Wouldn't it be better to compile regexp pattern in advance at top level? I don't know the real performance gain, but using precompiled regexp where possible is common sense to me.

if re.search(r'%\([^\)]+\)', self.success_url):

replace with:

percent_placeholder = re.compile(r'%\([^\)]+\)')

...

    def get_success_url():
        if percent_placeholder.search(self.success_url):

Change History (3)

comment:1 by Tomáš Ehrlich, 9 years ago

Has patch: set
Status: newassigned

comment:2 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In ea0ea7859a224225950a4df7c23eb3a7d823ddcd:

Fixed #24221 - Used precompiled regexp for percent-placeholder matching.

comment:3 by Tim Graham <timograham@…>, 9 years ago

In 2d990fb7fa6a04bb709aa9d7f687ec009c557c9e:

[1.8.x] Fixed #24221 - Used precompiled regexp for percent-placeholder matching.

Backport of ea0ea7859a224225950a4df7c23eb3a7d823ddcd from master

Note: See TracTickets for help on using tickets.
Back to Top