Commit 02bb977d authored by Andreas Jung's avatar Andreas Jung

Removed aliases like upper=string.join by native string method calls.

This increases performances by about 6 %  (using ab).
parent 0b62c54d
...@@ -215,11 +215,11 @@ class zhttp_handler: ...@@ -215,11 +215,11 @@ class zhttp_handler:
def handle_request(self,request): def handle_request(self,request):
self.hits.increment() self.hits.increment()
DebugLogger.log('B', id(request), '%s %s' % (string.upper(request.command), request.uri)) DebugLogger.log('B', id(request), '%s %s' % (request.command.upper(), request.uri))
size=get_header(CONTENT_LENGTH, request.header) size=get_header(CONTENT_LENGTH, request.header)
if size and size != '0': if size and size != '0':
size=string.atoi(size) size=int(size)
zhttp_collector(self, request, size) zhttp_collector(self, request, size)
else: else:
sin=StringIO() sin=StringIO()
...@@ -227,11 +227,6 @@ class zhttp_handler: ...@@ -227,11 +227,6 @@ class zhttp_handler:
def get_environment(self, request, def get_environment(self, request,
# These are strictly performance hackery... # These are strictly performance hackery...
split=string.split,
strip=string.strip,
join =string.join,
upper=string.upper,
lower=string.lower,
h2ehas=header2env.has_key, h2ehas=header2env.has_key,
h2eget=header2env.get, h2eget=header2env.get,
workdir=os.getcwd(), workdir=os.getcwd(),
...@@ -250,7 +245,7 @@ class zhttp_handler: ...@@ -250,7 +245,7 @@ class zhttp_handler:
server=request.channel.server server=request.channel.server
env = {} env = {}
env['REQUEST_METHOD']=upper(request.command) env['REQUEST_METHOD']=request.command.upper()
env['SERVER_PORT']=str(server.port) env['SERVER_PORT']=str(server.port)
env['SERVER_NAME']=server.server_name env['SERVER_NAME']=server.server_name
env['SERVER_SOFTWARE']=server.SERVER_IDENT env['SERVER_SOFTWARE']=server.SERVER_IDENT
...@@ -262,7 +257,7 @@ class zhttp_handler: ...@@ -262,7 +257,7 @@ class zhttp_handler:
else: else:
env['SCRIPT_NAME'] = self.uri_base env['SCRIPT_NAME'] = self.uri_base
try: try:
path_info=split(path,self.uri_base[1:],1)[1] path_info=path.split(self.uri_base[1:],1)[1]
except: except:
path_info='' path_info=''
env['PATH_INFO']=path_info env['PATH_INFO']=path_info
...@@ -284,13 +279,13 @@ class zhttp_handler: ...@@ -284,13 +279,13 @@ class zhttp_handler:
env_has=env.has_key env_has=env.has_key
for header in request.header: for header in request.header:
key,value=split(header,":",1) key,value=header.split(":",1)
key=lower(key) key=key.lower()
value=strip(value) value=value.strip()
if h2ehas(key) and value: if h2ehas(key) and value:
env[h2eget(key)]=value env[h2eget(key)]=value
else: else:
key='HTTP_%s' % upper(join(split(key, "-"), "_")) key='HTTP_%s' % ("_".join(key.split( "-"))).upper()
if value and not env_has(key): if value and not env_has(key):
env[key]=value env[key]=value
env.update(self.env_override) env.update(self.env_override)
...@@ -301,7 +296,7 @@ class zhttp_handler: ...@@ -301,7 +296,7 @@ class zhttp_handler:
s=get_header(CONTENT_LENGTH, request.header) s=get_header(CONTENT_LENGTH, request.header)
if s: if s:
s=string.atoi(s) s=int(s)
else: else:
s=0 s=0
DebugLogger.log('I', id(request), s) DebugLogger.log('I', id(request), s)
......
...@@ -215,11 +215,11 @@ class zhttp_handler: ...@@ -215,11 +215,11 @@ class zhttp_handler:
def handle_request(self,request): def handle_request(self,request):
self.hits.increment() self.hits.increment()
DebugLogger.log('B', id(request), '%s %s' % (string.upper(request.command), request.uri)) DebugLogger.log('B', id(request), '%s %s' % (request.command.upper(), request.uri))
size=get_header(CONTENT_LENGTH, request.header) size=get_header(CONTENT_LENGTH, request.header)
if size and size != '0': if size and size != '0':
size=string.atoi(size) size=int(size)
zhttp_collector(self, request, size) zhttp_collector(self, request, size)
else: else:
sin=StringIO() sin=StringIO()
...@@ -227,11 +227,6 @@ class zhttp_handler: ...@@ -227,11 +227,6 @@ class zhttp_handler:
def get_environment(self, request, def get_environment(self, request,
# These are strictly performance hackery... # These are strictly performance hackery...
split=string.split,
strip=string.strip,
join =string.join,
upper=string.upper,
lower=string.lower,
h2ehas=header2env.has_key, h2ehas=header2env.has_key,
h2eget=header2env.get, h2eget=header2env.get,
workdir=os.getcwd(), workdir=os.getcwd(),
...@@ -250,7 +245,7 @@ class zhttp_handler: ...@@ -250,7 +245,7 @@ class zhttp_handler:
server=request.channel.server server=request.channel.server
env = {} env = {}
env['REQUEST_METHOD']=upper(request.command) env['REQUEST_METHOD']=request.command.upper()
env['SERVER_PORT']=str(server.port) env['SERVER_PORT']=str(server.port)
env['SERVER_NAME']=server.server_name env['SERVER_NAME']=server.server_name
env['SERVER_SOFTWARE']=server.SERVER_IDENT env['SERVER_SOFTWARE']=server.SERVER_IDENT
...@@ -262,7 +257,7 @@ class zhttp_handler: ...@@ -262,7 +257,7 @@ class zhttp_handler:
else: else:
env['SCRIPT_NAME'] = self.uri_base env['SCRIPT_NAME'] = self.uri_base
try: try:
path_info=split(path,self.uri_base[1:],1)[1] path_info=path.split(self.uri_base[1:],1)[1]
except: except:
path_info='' path_info=''
env['PATH_INFO']=path_info env['PATH_INFO']=path_info
...@@ -284,13 +279,13 @@ class zhttp_handler: ...@@ -284,13 +279,13 @@ class zhttp_handler:
env_has=env.has_key env_has=env.has_key
for header in request.header: for header in request.header:
key,value=split(header,":",1) key,value=header.split(":",1)
key=lower(key) key=key.lower()
value=strip(value) value=value.strip()
if h2ehas(key) and value: if h2ehas(key) and value:
env[h2eget(key)]=value env[h2eget(key)]=value
else: else:
key='HTTP_%s' % upper(join(split(key, "-"), "_")) key='HTTP_%s' % ("_".join(key.split( "-"))).upper()
if value and not env_has(key): if value and not env_has(key):
env[key]=value env[key]=value
env.update(self.env_override) env.update(self.env_override)
...@@ -301,7 +296,7 @@ class zhttp_handler: ...@@ -301,7 +296,7 @@ class zhttp_handler:
s=get_header(CONTENT_LENGTH, request.header) s=get_header(CONTENT_LENGTH, request.header)
if s: if s:
s=string.atoi(s) s=int(s)
else: else:
s=0 s=0
DebugLogger.log('I', id(request), s) DebugLogger.log('I', id(request), s)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment