|
1 | 1 | use serde::{Deserialize, Serialize};
|
2 | 2 | use std::convert::TryFrom;
|
| 3 | +use std::sync::Arc; |
3 | 4 | use std::time::Duration;
|
4 | 5 |
|
5 | 6 | #[derive(Serialize, Deserialize, Debug, Clone)]
|
6 | 7 | #[serde(into = "InternalSelfProfile")]
|
7 | 8 | #[serde(from = "InternalSelfProfile")]
|
8 | 9 | pub struct SelfProfile {
|
9 |
| - pub query_data: Vec<QueryData>, |
| 10 | + pub query_data: Arc<Vec<QueryData>>, |
10 | 11 | }
|
11 | 12 |
|
12 | 13 | impl Into<InternalSelfProfile> for SelfProfile {
|
@@ -42,7 +43,12 @@ impl Into<InternalSelfProfile> for SelfProfile {
|
42 | 43 | impl From<InternalSelfProfile> for SelfProfile {
|
43 | 44 | fn from(profile: InternalSelfProfile) -> SelfProfile {
|
44 | 45 | match profile {
|
45 |
| - InternalSelfProfile::Rustc { query_data } => SelfProfile { query_data }, |
| 46 | + InternalSelfProfile::Rustc { mut query_data } => { |
| 47 | + query_data.shrink_to_fit(); |
| 48 | + SelfProfile { |
| 49 | + query_data: Arc::new(query_data), |
| 50 | + } |
| 51 | + } |
46 | 52 | InternalSelfProfile::Perf {
|
47 | 53 | label,
|
48 | 54 | self_time,
|
@@ -73,7 +79,10 @@ impl From<InternalSelfProfile> for SelfProfile {
|
73 | 79 | incremental_load_time: incremental_load_time.next().unwrap(),
|
74 | 80 | });
|
75 | 81 | }
|
76 |
| - SelfProfile { query_data } |
| 82 | + query_data.shrink_to_fit(); |
| 83 | + SelfProfile { |
| 84 | + query_data: Arc::new(query_data), |
| 85 | + } |
77 | 86 | }
|
78 | 87 | }
|
79 | 88 | }
|
|
0 commit comments