Mercurial > public > mercurial-scm > hg
comparison mercurial/statprof.py @ 52580:f4d1f0713b49
statprof: don't leak a file descriptor when loading data files
I wanted to use `util.readfiles()` here, but it looks like very little core code
is imported, and I assume that's by design?
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 17 Dec 2024 01:35:52 -0500 |
parents | ef83646d5f7d |
children | dc36535a5edc |
comparison
equal
deleted
inserted
replaced
52579:72d461cbd1f3 | 52580:f4d1f0713b49 |
---|---|
395 ] | 395 ] |
396 file.write(b"%d\0%s\n" % (time, b'\0'.join(sites))) | 396 file.write(b"%d\0%s\n" % (time, b'\0'.join(sites))) |
397 | 397 |
398 | 398 |
399 def load_data(path): | 399 def load_data(path): |
400 lines = open(path, 'rb').read().splitlines() | 400 with open(path, 'rb') as fp: |
401 lines = fp.read().splitlines() | |
401 | 402 |
402 state.accumulated_time = [float(value) for value in lines[0].split()] | 403 state.accumulated_time = [float(value) for value in lines[0].split()] |
403 state.samples = [] | 404 state.samples = [] |
404 for line in lines[1:]: | 405 for line in lines[1:]: |
405 parts = line.split(b'\0') | 406 parts = line.split(b'\0') |