Avoid unnecessary growth of python lists

The path argument of checkProg* was added to the PATH list in a nested
loop such that the list doubles in size each time the loop is executed,
thus also slowing down detection of missing programs.
This commit is contained in:
Enrico Forestieri 2015-06-16 21:08:25 +02:00
parent 565b4e9fd2
commit 1151d06e81
2 changed files with 12 additions and 8 deletions

View File

@ -250,6 +250,11 @@ def checkProg(description, progs, rc_entry = [], path = [], not_found = ''):
sys.exit(2) sys.exit(2)
logger.info('checking for ' + description + '...') logger.info('checking for ' + description + '...')
## print '(' + ','.join(progs) + ')', ## print '(' + ','.join(progs) + ')',
additional_path = path
path = os.environ["PATH"].split(os.pathsep) + additional_path
extlist = ['']
if "PATHEXT" in os.environ:
extlist = extlist + os.environ["PATHEXT"].split(os.pathsep)
global java, perl global java, perl
for idx in range(len(progs)): for idx in range(len(progs)):
# ac_prog may have options, ac_word is the command name # ac_prog may have options, ac_word is the command name
@ -260,10 +265,6 @@ def checkProg(description, progs, rc_entry = [], path = [], not_found = ''):
if ac_word.endswith('.pl') and perl == '': if ac_word.endswith('.pl') and perl == '':
continue continue
msg = '+checking for "' + ac_word + '"... ' msg = '+checking for "' + ac_word + '"... '
path = os.environ["PATH"].split(os.pathsep) + path
extlist = ['']
if "PATHEXT" in os.environ:
extlist = extlist + os.environ["PATHEXT"].split(os.pathsep)
for ac_dir in path: for ac_dir in path:
if hasattr(os, "access") and not os.access(ac_dir, os.F_OK): if hasattr(os, "access") and not os.access(ac_dir, os.F_OK):
continue continue
@ -302,6 +303,11 @@ def checkProgAlternatives(description, progs, rc_entry = [], alt_rc_entry = [],
sys.exit(2) sys.exit(2)
logger.info('checking for ' + description + '...') logger.info('checking for ' + description + '...')
## print '(' + ','.join(progs) + ')', ## print '(' + ','.join(progs) + ')',
additional_path = path
path = os.environ["PATH"].split(os.pathsep) + additional_path
extlist = ['']
if "PATHEXT" in os.environ:
extlist = extlist + os.environ["PATHEXT"].split(os.pathsep)
found_prime = False found_prime = False
real_ac_dir = '' real_ac_dir = ''
real_ac_word = not_found real_ac_word = not_found
@ -315,10 +321,6 @@ def checkProgAlternatives(description, progs, rc_entry = [], alt_rc_entry = [],
if ac_word.endswith('.pl') and perl == '': if ac_word.endswith('.pl') and perl == '':
continue continue
msg = '+checking for "' + ac_word + '"... ' msg = '+checking for "' + ac_word + '"... '
path = os.environ["PATH"].split(os.pathsep) + path
extlist = ['']
if "PATHEXT" in os.environ:
extlist = extlist + os.environ["PATHEXT"].split(os.pathsep)
found_alt = False found_alt = False
for ac_dir in path: for ac_dir in path:
if hasattr(os, "access") and not os.access(ac_dir, os.F_OK): if hasattr(os, "access") and not os.access(ac_dir, os.F_OK):

View File

@ -246,6 +246,8 @@ What's new
- Fix parsing of Requires layout tag if it uses tabs instead of spaces - Fix parsing of Requires layout tag if it uses tabs instead of spaces
(bug 9518). (bug 9518).
- Don't repeatedly check for missing programs when reconfiguring.
* DOCUMENTATION AND LOCALIZATION * DOCUMENTATION AND LOCALIZATION