Skip to content

Commit

Permalink
perf: don't read full line_bits table each time
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed May 28, 2024
1 parent c45ebac commit b9aff50
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions coverage/sqldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,16 +789,14 @@ def update(
if lines:
self._choose_lines_or_arcs(lines=True)

with con.execute(
"select file.path, context.context, line_bits.numbits " +
"from line_bits " +
"inner join file on file.id = line_bits.file_id " +
"inner join context on context.id = line_bits.context_id",
) as cur:
for path, context, numbits in cur:
key = (aliases_map(path), context)
if key in lines:
lines[key] = numbits_union(lines[key], numbits)
for (file, context), numbits in lines.items():
with con.execute(
"select numbits from line_bits where file_id = ? and context_id = ?",
(file_ids[file], context_ids[context]),
) as cur:
existing = list(cur)
if existing:
lines[(file, context)] = numbits_union(numbits, existing[0][0])

con.executemany_void(
"insert or replace into line_bits " +
Expand Down

0 comments on commit b9aff50

Please sign in to comment.