Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion profiling/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub struct StringIdLocation {
pub line: i64,
}

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

Expand Down
23 changes: 14 additions & 9 deletions profiling/src/internal/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,24 @@ impl LabelId {
/// You should only use the impl functions to modify this.
#[derive(Clone, Debug, Default, Eq, PartialEq, Hash)]
pub struct LabelSet {
// Guaranteed to be sorted by [Self::new]
sorted_labels: Box<[LabelId]>,
labels: Box<[LabelId]>,
}

impl LabelSet {
pub fn iter(&self) -> core::slice::Iter<'_, LabelId> {
self.sorted_labels.iter()
}

pub fn new(mut v: Vec<LabelId>) -> Self {
v.sort_unstable();
let sorted_labels = v.into_boxed_slice();
Self { sorted_labels }
self.labels.iter()
}

pub fn new(labels: Box<[LabelId]>) -> Self {
// Once upon a time label ids were guaranteed to be sorted. However,
// this makes testing difficult because the order of input labels and
// output labels can make a difference.
// Unless there is some reason lost to time, we do not need to sort
// these. Save some cycles, and if a given language increases memory,
// then it means they aren't adding labels in the same order every
// time, and they should examine that--but it shouldn't be a
// correctness issue, as far as I know.
Self { labels }
}
}

Expand Down
Loading
Loading