Skip to content

Commit 0225ec4

Browse files
committed
tiny optimization
1 parent daa84eb commit 0225ec4

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/encode/folded.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ use crate::backend;
33

44
use backend::types::{Report, EncodedReport};
55

6-
pub fn encode(reports: Vec<Report>) -> Vec<EncodedReport> {
6+
pub fn encode(reports: &Vec<Report>) -> Vec<EncodedReport> {
77
reports.into_iter()
88
.map(|r| {
99
EncodedReport {
1010
format: "folded".to_string(),
1111
content_type: "binary/octet-stream".to_string(),
1212
content_encoding: "".to_string(),
1313
data: r.to_string().into_bytes(),
14-
metadata: r.metadata,
14+
metadata: r.metadata.to_owned(),
1515
}
1616
}).collect()
1717
}

src/encode/pprof.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl PProfBuilder {
8080
}
8181
}
8282

83-
pub fn encode(reports: Vec<Report>, sample_rate: u32, start_time_nanos: u64, duration_nanos: u64) -> Vec<EncodedReport> {
83+
pub fn encode(reports: &Vec<Report>, sample_rate: u32, start_time_nanos: u64, duration_nanos: u64) -> Vec<EncodedReport> {
8484
let mut b = PProfBuilder {
8585
strings: HashMap::new(),
8686
functions: HashMap::new(),
@@ -116,7 +116,7 @@ pub fn encode(reports: Vec<Report>, sample_rate: u32, start_time_nanos: u64, dur
116116
unit: milliseconds,
117117
})
118118
}
119-
for report in &reports {
119+
for report in reports {
120120
for (stacktrace, value) in &report.data {
121121
let mut sample = Sample {
122122
location_id: vec![],

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub mod error;
5151
pub mod pyroscope;
5252
pub mod session;
5353
pub mod timer;
54+
pub mod encode;
5455

5556
// Private modules
5657
mod utils;
57-
mod encode;

src/session.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ impl Session {
162162
fn encode_reports(&self, reports: Vec<Report>) -> Vec<EncodedReport> {
163163
log::debug!(target: LOG_TAG, "Encoding {} reports to {:?}", reports.len(), self.config.report_encoding);
164164
match &self.config.report_encoding {
165-
ReportEncoding::FOLDED => folded::encode(reports),
166-
ReportEncoding::PPROF => pprof::encode(reports,
165+
ReportEncoding::FOLDED => folded::encode(&reports),
166+
ReportEncoding::PPROF => pprof::encode(&reports,
167167
self.config.sample_rate,
168168
self.from * 1_000_000,
169169
(self.until - self.from) * 1_000_000,

0 commit comments

Comments
 (0)