Skip to content

Commit b9aff50

Browse files
committed
perf: don't read full line_bits table each time
1 parent c45ebac commit b9aff50

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

coverage/sqldata.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -789,16 +789,14 @@ def update(
789789
if lines:
790790
self._choose_lines_or_arcs(lines=True)
791791

792-
with con.execute(
793-
"select file.path, context.context, line_bits.numbits " +
794-
"from line_bits " +
795-
"inner join file on file.id = line_bits.file_id " +
796-
"inner join context on context.id = line_bits.context_id",
797-
) as cur:
798-
for path, context, numbits in cur:
799-
key = (aliases_map(path), context)
800-
if key in lines:
801-
lines[key] = numbits_union(lines[key], numbits)
792+
for (file, context), numbits in lines.items():
793+
with con.execute(
794+
"select numbits from line_bits where file_id = ? and context_id = ?",
795+
(file_ids[file], context_ids[context]),
796+
) as cur:
797+
existing = list(cur)
798+
if existing:
799+
lines[(file, context)] = numbits_union(numbits, existing[0][0])
802800

803801
con.executemany_void(
804802
"insert or replace into line_bits " +

0 commit comments

Comments
 (0)