diff options
author | Ms2ger <Ms2ger@gmail.com> | 2015-08-26 16:19:01 +0200 |
---|---|---|
committer | Ms2ger <Ms2ger@gmail.com> | 2015-08-26 16:19:01 +0200 |
commit | 18b9532b259c5e5431ef36f5be2a34e3e5ebd63c (patch) | |
tree | 72e536d9e979ee4f56aa354b37e7d69769719a1f /components/devtools | |
parent | 5f9097c0b409c51cb8bc7e2d603747ba716a8d9d (diff) | |
download | servo-18b9532b259c5e5431ef36f5be2a34e3e5ebd63c.tar.gz servo-18b9532b259c5e5431ef36f5be2a34e3e5ebd63c.zip |
Remove Emitter::markers.
The vector is filled in and immediately emptied again. It is clearer to
keep the vector in the caller instead.
Diffstat (limited to 'components/devtools')
-rw-r--r-- | components/devtools/actors/timeline.rs | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/components/devtools/actors/timeline.rs b/components/devtools/actors/timeline.rs index a608ff1380e..17327b1043e 100644 --- a/components/devtools/actors/timeline.rs +++ b/components/devtools/actors/timeline.rs @@ -7,7 +7,6 @@ use msg::constellation_msg::PipelineId; use rustc_serialize::{json, Encoder, Encodable}; use std::cell::RefCell; use std::collections::{HashMap, VecDeque}; -use std::mem; use std::net::TcpStream; use std::sync::mpsc::channel; use std::sync::{Arc, Mutex}; @@ -37,7 +36,6 @@ pub struct TimelineActor { struct Emitter { from: String, stream: TcpStream, - markers: Vec<TimelineMarkerReply>, registry: Arc<Mutex<ActorRegistry>>, start_stamp: PreciseTime, @@ -154,7 +152,8 @@ impl TimelineActor { /// from queue and add marker to emitter /// Return true if closed (IntervalStart + IntervalEnd) pair was founded fn group(queue: &mut VecDeque<TimelineMarker>, depth: usize, - start_payload: Option<TimelineMarker>, emitter: &mut Emitter) -> bool { + start_payload: Option<TimelineMarker>, emitter: &Emitter, + markers: &mut Vec<TimelineMarkerReply>) -> bool { if let Some(start_payload) = start_payload { if start_payload.metadata != TracingMetadata::IntervalStart { @@ -166,13 +165,13 @@ impl TimelineActor { TracingMetadata::IntervalEnd => { if depth == 0 { // Emit TimelineMarkerReply, pair was found - emitter.add_marker(start_payload, end_payload); + markers.push(emitter.marker(start_payload, end_payload)); } return true; } TracingMetadata::IntervalStart => { - if group(queue, depth + 1, Some(end_payload), emitter) { - return group(queue, depth, Some(start_payload), emitter); + if group(queue, depth + 1, Some(end_payload), emitter, markers) { + return group(queue, depth, Some(start_payload), emitter, markers); } else { queue.push_front(start_payload); } @@ -211,11 +210,12 @@ impl TimelineActor { } // Emit all markers + let mut markers = vec![]; for (_, queue) in &mut queues { let start_payload = queue.pop_front(); - group(queue, 0, start_payload, &mut emitter); + group(queue, 0, start_payload, &emitter, &mut markers); } - emitter.send(); + emitter.send(markers); sleep_ms(DEFAULT_TIMELINE_DATA_PULL_TIMEOUT); } @@ -328,7 +328,6 @@ impl Emitter { Emitter { from: name, stream: stream, - markers: Vec::new(), registry: registry, start_stamp: start_stamp, @@ -337,21 +336,22 @@ impl Emitter { } } - fn add_marker(&mut self, start_payload: TimelineMarker, end_payload: TimelineMarker) -> () { - self.markers.push(TimelineMarkerReply { + fn marker(&self, start_payload: TimelineMarker, end_payload: TimelineMarker) + -> TimelineMarkerReply { + TimelineMarkerReply { name: start_payload.name, start: HighResolutionStamp::new(self.start_stamp, start_payload.time), end: HighResolutionStamp::new(self.start_stamp, end_payload.time), stack: start_payload.stack, endStack: end_payload.stack, - }); + } } - fn send(&mut self) -> () { + fn send(&mut self, markers: Vec<TimelineMarkerReply>) -> () { let end_time = PreciseTime::now(); let reply = MarkersEmitterReply { __type__: "markers".to_string(), - markers: mem::replace(&mut self.markers, Vec::new()), + markers: markers, from: self.from.clone(), endTime: HighResolutionStamp::new(self.start_stamp, end_time), }; |