Replace textwrap with fast standard code
This improves on commit 4350c17604
We found a major performance regression in keystoneclient
when using PKI tokens, related to http://bugs.python.org/issue25870
It can be tested with
time python -c "import textwrap; textwrap.wrap('x'*9000, 64)"
which has a complexity of O(n*n)
because it uses certain regexps in python versions before 3.5.
Closes-Bug: #1526686
Related-Bug: #1404402
Change-Id: Ibc81907c4d9db2c09fff41ccf21345fbdb19202d
This commit is contained in:
@@ -23,7 +23,6 @@ import base64
|
||||
import errno
|
||||
import hashlib
|
||||
import logging
|
||||
import textwrap
|
||||
import zlib
|
||||
|
||||
from debtcollector import removals
|
||||
@@ -242,7 +241,7 @@ def token_to_cms(signed_text):
|
||||
copy_of_text = signed_text.replace('-', '/')
|
||||
|
||||
lines = ['-----BEGIN CMS-----']
|
||||
lines += textwrap.wrap(copy_of_text, 64)
|
||||
lines += [copy_of_text[n:n + 64] for n in range(0, len(copy_of_text), 64)]
|
||||
lines.append('-----END CMS-----\n')
|
||||
return '\n'.join(lines)
|
||||
|
||||
|
Reference in New Issue
Block a user