mirror of
https://github.com/servo/servo.git
synced 2025-06-27 02:23:41 +01:00
Avoid double copying urls in collect_reports.
This commit is contained in:
parent
0d16a2a54e
commit
7bc34d0a1b
1 changed files with 6 additions and 4 deletions
|
@ -1253,27 +1253,29 @@ impl ScriptThread {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collect_reports(&self, reports_chan: ReportsChan) {
|
fn collect_reports(&self, reports_chan: ReportsChan) {
|
||||||
let mut urls = vec![];
|
let mut path_seg = String::from("url(");
|
||||||
let mut dom_tree_size = 0;
|
let mut dom_tree_size = 0;
|
||||||
let mut reports = vec![];
|
let mut reports = vec![];
|
||||||
|
|
||||||
for document in self.documents.borrow().iter() {
|
for document in self.documents.borrow().iter() {
|
||||||
let current_url = document.url().to_string();
|
let current_url = document.url().as_str();
|
||||||
|
|
||||||
for child in document.upcast::<Node>().traverse_preorder() {
|
for child in document.upcast::<Node>().traverse_preorder() {
|
||||||
dom_tree_size += heap_size_of_self_and_children(&*child);
|
dom_tree_size += heap_size_of_self_and_children(&*child);
|
||||||
}
|
}
|
||||||
dom_tree_size += heap_size_of_self_and_children(document.window());
|
dom_tree_size += heap_size_of_self_and_children(document.window());
|
||||||
|
|
||||||
|
if reports.len() > 0 { path_seg.push_str(", "); }
|
||||||
|
path_seg.push_str(current_url);
|
||||||
|
|
||||||
reports.push(Report {
|
reports.push(Report {
|
||||||
path: path![format!("url({})", current_url), "dom-tree"],
|
path: path![format!("url({})", current_url), "dom-tree"],
|
||||||
kind: ReportKind::ExplicitJemallocHeapSize,
|
kind: ReportKind::ExplicitJemallocHeapSize,
|
||||||
size: dom_tree_size,
|
size: dom_tree_size,
|
||||||
});
|
});
|
||||||
urls.push(current_url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let path_seg = format!("url({})", urls.join(", "));
|
path_seg.push_str(")");
|
||||||
reports.extend(get_reports(self.get_cx(), path_seg));
|
reports.extend(get_reports(self.get_cx(), path_seg));
|
||||||
reports_chan.send(reports);
|
reports_chan.send(reports);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue