Module: check_mk
Branch: master
Commit: 800273c90235068e30db3f85e1bebb8bc9e93f00
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=800273c9023506…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Sep 27 10:03:56 2012 +0200
Some small performance improvement
---
web/htdocs/htmllib.py | 15 +++++----------
1 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 69257fa..9805478 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -87,25 +87,20 @@ def attrencode(value):
# is saving more then 90% of the total HTML generating time
# on more complex pages!
def urlencode_vars(vars):
- output = ""
+ output = []
for varname, value in vars:
- if output != "":
- output += "&"
-
if type(value) == int:
value = str(value)
elif type(value) == unicode:
value = value.encode("utf-8")
- output += varname
- output += "="
try:
# urllib is not able to encode non-Ascii characters. Yurks
- output += urllib.quote(value)
+ output.append(varname + '=' + urllib.quote(value))
except:
- output += urlencode(value) # slow but working
+ output.append(varname + '=' + urlencode(value)) # slow but working
- return output
+ return '&'.join(output)
def urlencode(value):
if type(value) == unicode:
@@ -332,7 +327,7 @@ class html:
# [('varname1', value1), ('varname2', value2) ]
def makeuri(self, addvars, remove_prefix = None):
- vars = [ (v, self.var(v)) for v in self.req.vars if not
v.startswith("_") ]
+ vars = [ (v, self.var(v)) for v in self.req.vars if v[0] != "_" ]
if remove_prefix != None:
vars = [ i for i in vars if not i[0].startswith(remove_prefix) ]
return self.req.myfile + ".py?" + urlencode_vars(vars + addvars)