Remove an unnecessary optimisation #8850
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Remove an unnessary optimisation where
AuthCookieService.verify_cookie()
(a method that is only ever calledby
CookiePolicy.identity()
, and returns the user identity representedby the request's auth cookie) caches the user object as
self._user
sothat it can just return it if called again, rather than recomputing it
from the cookie.
This optimisation looks potentially dodgy to me because
self._user
isnot only set by the
verify_cookie()
method but also bycreate_cookie()
.We probably don't need to optimise this but if we do want to optimise it
the right way would be to cache the final return value of the
AuthCookieService.verify_cookie()
method (not an intermediate value)or cache the return value of the higher-level
CookiePolicy.identity()
method that calls it.