summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpankajp <pankaj86@gmail.com>2018-05-24 12:43:32 +0000
committerpankajp <pankaj86@gmail.com>2018-05-24 12:43:32 +0000
commit5d8c7de3956e5686549f4d086738b6a59a285890 (patch)
tree6a59d6fab05feb8f0678a1d199a7dd36e5f5ed1d
parentb166919e38a2323ca52582bcb228be77ab96c3e5 (diff)
downloadpython-coveragepy-5d8c7de3956e5686549f4d086738b6a59a285890.tar.gz
Prevent expensive relayout in loop in html report js
Faster html report loading in browser by avoiding unneeded expensive layouts in the loop to generate markers.
-rw-r--r--coverage/htmlfiles/coverage_html.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/coverage/htmlfiles/coverage_html.js b/coverage/htmlfiles/coverage_html.js
index f6f5de2..b7fbd9c 100644
--- a/coverage/htmlfiles/coverage_html.js
+++ b/coverage/htmlfiles/coverage_html.js
@@ -555,11 +555,14 @@ coverage.resize_scroll_markers = function () {
var previous_line = -99,
last_mark,
- last_top;
+ last_top,
+ offsets = {};
+ // Calculate line offsets outside loop to prevent relayouts
+ c.missed_lines.each(function(){offsets[this.id] = $(this).offset().top});
c.missed_lines.each(function () {
- var line_top = Math.round($(this).offset().top * marker_scale),
- id_name = $(this).attr('id'),
+ var id_name = $(this).attr('id'),
+ line_top = Math.round(offsets[id_name] * marker_scale),
line_number = parseInt(id_name.substring(1, id_name.length));
if (line_number === previous_line + 1) {