#33433: Avoid calling resolve() when unnecessary in technical_404_response
------------------------------------------------+------------------------
               Reporter:  Hrushikesh Vaidya     |          Owner:  nobody
                   Type:  Cleanup/optimization  |         Status:  new
              Component:  Core (URLs)           |        Version:  4.0
               Severity:  Normal                |       Keywords:
           Triage Stage:  Unreviewed            |      Has patch:  0
    Needs documentation:  0                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  0
                  UI/UX:  0                     |
------------------------------------------------+------------------------
 As discussed in the comments of this
 [https://github.com/django/django/pull/15286#issuecomment-1008798626 PR],
 we can avoid calling `resolve(request.path)` in the
 `technical_404_response` if `request.resolver_match` is already set.

 This fix first checks if the resolver is `None` before calling
 `resolve()`, and avoids the call entirely if we have already resolved.
 {{{
 caller = ''
 if resolver_match is None:
     try:
         resolver_match = resolve(request.path)
     except Http404:
         pass

 if resolver_match is not None:
     caller = resolver_match._func_path
 }}}

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/055.7c4e580fc9f944edd7a7ce423c4d8a68%40djangoproject.com.

Reply via email to