-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
bpo-34002: Minor efficiency and clarity improvements in email package. #7999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
d8bc2c0
51e14f8
c6168d1
b7e4749
4c61d82
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -259,21 +259,13 @@ def decode_params(params): | |
|
||
params is a sequence of 2-tuples containing (param name, string value). | ||
""" | ||
# Copy params so we don't mess with the original | ||
params = params[:] | ||
new_params = [] | ||
new_params = [params[0]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's possible for the first params element, though the others are implicitly checked by the unpacking for-loop. Looking at the usage of If that's not satisfactory, I'll revert to:
|
||
# Map parameter's name to a list of continuations. The values are a | ||
# 3-tuple of the continuation number, the string value, and a flag | ||
# specifying whether a particular segment is %-encoded. | ||
rfc2231_params = {} | ||
name, value = params.pop(0) | ||
new_params.append((name, value)) | ||
while params: | ||
name, value = params.pop(0) | ||
if name.endswith('*'): | ||
encoded = True | ||
else: | ||
encoded = False | ||
for name, value in params[1:]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True. The real benefit is avoiding repeated There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But the code can be made more optimal if avoid a copy. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks to me that the final value of 'encoded' only depends on the final value of name. If so, the loop is equivalent to
Otherwise, one can skip-iterate without copying with
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Each iteration of the loop uses the
|
||
encoded = name.endswith('*') | ||
value = unquote(value) | ||
mo = rfc2231_continuation.match(name) | ||
if mo: | ||
|
Uh oh!
There was an error while loading. Please reload this page.