comparison mercurial/hgweb/hgwebdir_mod.py @ 14076:924c82157d46

url: move URL parsing functions into util to improve startup time The introduction of the new URL parsing code has created a startup time regression. This is mainly due to the use of url.hasscheme() in the ui class. It ends up importing many libraries that the url module requires. This fix helps marginally, but if we can get rid of the urllib import in the URL parser all together, startup time will go back to normal. perfstartup time before the URL refactoring (8796fb6af67e): ! wall 0.050692 comb 0.000000 user 0.000000 sys 0.000000 (best of 100) current startup time (139fb11210bb): ! wall 0.070685 comb 0.000000 user 0.000000 sys 0.000000 (best of 100) after this change: ! wall 0.064667 comb 0.000000 user 0.000000 sys 0.000000 (best of 100)
author Brodie Rao <brodie@bitheap.org>
date Sat, 30 Apr 2011 09:43:20 -0700
parents 938fbeacac84
children 44382887d012 dd74cd1e5d49
comparison
equal deleted inserted replaced
14075:bc101902a68d 14076:924c82157d46
7 # GNU General Public License version 2 or any later version. 7 # GNU General Public License version 2 or any later version.
8 8
9 import os, re, time 9 import os, re, time
10 from mercurial.i18n import _ 10 from mercurial.i18n import _
11 from mercurial import ui, hg, scmutil, util, templater 11 from mercurial import ui, hg, scmutil, util, templater
12 from mercurial import error, encoding, url 12 from mercurial import error, encoding
13 from common import ErrorResponse, get_mtime, staticfile, paritygen, \ 13 from common import ErrorResponse, get_mtime, staticfile, paritygen, \
14 get_contact, HTTP_OK, HTTP_NOT_FOUND, HTTP_SERVER_ERROR 14 get_contact, HTTP_OK, HTTP_NOT_FOUND, HTTP_SERVER_ERROR
15 from hgweb_mod import hgweb 15 from hgweb_mod import hgweb
16 from request import wsgirequest 16 from request import wsgirequest
17 import webutil 17 import webutil
362 "sessionvars": sessionvars}) 362 "sessionvars": sessionvars})
363 return tmpl 363 return tmpl
364 364
365 def updatereqenv(self, env): 365 def updatereqenv(self, env):
366 if self._baseurl is not None: 366 if self._baseurl is not None:
367 u = url.url(self._baseurl) 367 u = util.url(self._baseurl)
368 env['SERVER_NAME'] = u.host 368 env['SERVER_NAME'] = u.host
369 if u.port: 369 if u.port:
370 env['SERVER_PORT'] = u.port 370 env['SERVER_PORT'] = u.port
371 env['SCRIPT_NAME'] = '/' + u.path 371 env['SCRIPT_NAME'] = '/' + u.path