-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(profiling): backup sample types/period
This breaks a dependency on the string table implementation details to be able to reset a profile and preserve the sample types and period. It does cause more allocations, though. Adds api::ValueType::new and uses it instead of constructing it directly, because in most cases with `new` it becomes a single line instead of four.
- Loading branch information
1 parent
a97f7d1
commit fa7a21f
Showing
8 changed files
with
201 additions
and
201 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2021-Present Datadog, Inc. https://www.datadoghq.com/ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use crate::api::{Period, ValueType}; | ||
|
||
#[derive(Clone)] | ||
pub struct OwnedValueType { | ||
pub typ: Box<str>, | ||
pub unit: Box<str>, | ||
} | ||
|
||
impl<'a> From<&'a ValueType<'a>> for OwnedValueType { | ||
#[inline] | ||
fn from(value_type: &'a ValueType<'a>) -> Self { | ||
Self { | ||
typ: String::from(value_type.r#type).into(), | ||
unit: String::from(value_type.unit).into(), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Clone)] | ||
pub struct OwnedPeriod { | ||
pub typ: OwnedValueType, | ||
pub value: i64, | ||
} | ||
|
||
impl<'a> From<&'a Period<'a>> for OwnedPeriod { | ||
#[inline] | ||
fn from(period: &'a Period<'a>) -> Self { | ||
Self { | ||
typ: OwnedValueType::from(&period.r#type), | ||
value: period.value, | ||
} | ||
} | ||
} |
Oops, something went wrong.