Skip to content

Commit

Permalink
Merge pull request #226 from carsonip/faster-unfold
Browse files Browse the repository at this point in the history
Faster encodedword unfold by 15x
  • Loading branch information
thrawn01 authored Oct 24, 2019
2 parents 7c2e67d + 98c2c9b commit efe6e46
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions flanker/mime/message/headers/encodedword.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

_log = logging.getLogger(__name__)

_RE_FOLDING_WHITE_SPACES = re.compile(r"(\n\r?|\r\n?)(\s*)")
_RE_FOLDING_WHITE_SPACES = re.compile(r"(?:\n\r?|\r\n?)")

# This spec refers to http://tools.ietf.org/html/rfc2047
_RE_ENCODED_WORD = re.compile(r'''(?P<encodedWord>
Expand All @@ -31,7 +31,7 @@ def unfold(value):
treated in its unfolded form for further syntactic and semantic
evaluation.
"""
return re.sub(_RE_FOLDING_WHITE_SPACES, r'\2', value)
return _RE_FOLDING_WHITE_SPACES.sub('', value)


def decode(header):
Expand Down

0 comments on commit efe6e46

Please sign in to comment.