Skip to content

Commit a8e4daa

Browse files
authored
Merge branch 'main' into levi/buildx
2 parents cb0a362 + daf50ad commit a8e4daa

File tree

5 files changed

+257
-146
lines changed

5 files changed

+257
-146
lines changed

profiling/src/api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pub struct StringIdLocation {
125125
pub line: i64,
126126
}
127127

128-
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
128+
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Hash, Ord, PartialOrd)]
129129
pub struct Label<'a> {
130130
pub key: &'a str,
131131

profiling/src/internal/label.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,24 @@ impl LabelId {
105105
/// You should only use the impl functions to modify this.
106106
#[derive(Clone, Debug, Default, Eq, PartialEq, Hash)]
107107
pub struct LabelSet {
108-
// Guaranteed to be sorted by [Self::new]
109-
sorted_labels: Box<[LabelId]>,
108+
labels: Box<[LabelId]>,
110109
}
111110

112111
impl LabelSet {
113112
pub fn iter(&self) -> core::slice::Iter<'_, LabelId> {
114-
self.sorted_labels.iter()
115-
}
116-
117-
pub fn new(mut v: Vec<LabelId>) -> Self {
118-
v.sort_unstable();
119-
let sorted_labels = v.into_boxed_slice();
120-
Self { sorted_labels }
113+
self.labels.iter()
114+
}
115+
116+
pub fn new(labels: Box<[LabelId]>) -> Self {
117+
// Once upon a time label ids were guaranteed to be sorted. However,
118+
// this makes testing difficult because the order of input labels and
119+
// output labels can make a difference.
120+
// Unless there is some reason lost to time, we do not need to sort
121+
// these. Save some cycles, and if a given language increases memory,
122+
// then it means they aren't adding labels in the same order every
123+
// time, and they should examine that--but it shouldn't be a
124+
// correctness issue, as far as I know.
125+
Self { labels }
121126
}
122127
}
123128

0 commit comments

Comments
 (0)