summaryrefslogtreecommitdiff
path: root/keystoneclient/common
diff options
context:
space:
mode:
authorBernhard M. Wiedemann <bwiedemann@suse.de>2015-12-02 12:47:33 +0100
committerBernhard M. Wiedemann <bwiedemann@suse.de>2015-12-16 10:47:39 +0100
commitfde0bf77d6a89ee84e62461bc0d4c2cdfd809c48 (patch)
treed0462f9d166e83998a60de4710993d10d990fcae /keystoneclient/common
parentbeb62b6e1338e70d888065da5271d88824fa9ec5 (diff)
downloadpython-keystoneclient-fde0bf77d6a89ee84e62461bc0d4c2cdfd809c48.tar.gz
Replace textwrap with fast standard code
This improves on commit 4350c176048b8d159d08b82b915e9544ac9dee6f 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
Diffstat (limited to 'keystoneclient/common')
-rw-r--r--keystoneclient/common/cms.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/keystoneclient/common/cms.py b/keystoneclient/common/cms.py
index c1260d3..da72f2d 100644
--- a/keystoneclient/common/cms.py
+++ b/keystoneclient/common/cms.py
@@ -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)