From: Raymond Hettinger Date: Sat, 10 Sep 2005 02:27:41 +0000 (+0000) Subject: Simplify and speed-up quote_plus(). X-Git-Tag: v2.5a0~1397 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=957b1266492877d97a790a5698a9492512e5b8cd;p=thirdparty%2FPython%2Fcpython.git Simplify and speed-up quote_plus(). --- diff --git a/Lib/urllib.py b/Lib/urllib.py index b8ba4540226c..2889b3dbfb0d 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -1115,12 +1115,9 @@ def quote(s, safe = '/'): def quote_plus(s, safe = ''): """Quote the query fragment of a URL; replacing ' ' with '+'""" if ' ' in s: - l = s.split(' ') - for i in range(len(l)): - l[i] = quote(l[i], safe) - return '+'.join(l) - else: - return quote(s, safe) + s = s.replace(' ', '+') + safe += '+' + return quote(s, safe) def urlencode(query,doseq=0): """Encode a sequence of two-element tuples or dictionary into a URL query string.