Make MachBackend::triple return &Triple

This avoids an unnecessary clone
This commit is contained in:
bjorn3
2022-01-03 19:47:33 +01:00
parent 4915162230
commit 8d1fc75b6b
6 changed files with 10 additions and 13 deletions

View File

@@ -14,16 +14,13 @@ use target_lexicon::Triple;
/// A wrapper around a `MachBackend` that provides a `TargetIsa` impl.
pub struct TargetIsaAdapter {
backend: Box<dyn MachBackend + Send + Sync + 'static>,
triple: Triple,
}
impl TargetIsaAdapter {
/// Create a new `TargetIsa` wrapper around a `MachBackend`.
pub fn new<B: MachBackend + Send + Sync + 'static>(backend: B) -> TargetIsaAdapter {
let triple = backend.triple();
TargetIsaAdapter {
backend: Box::new(backend),
triple,
}
}
}
@@ -44,7 +41,7 @@ impl TargetIsa for TargetIsaAdapter {
}
fn triple(&self) -> &Triple {
&self.triple
self.backend.triple()
}
fn flags(&self) -> &Flags {

View File

@@ -390,7 +390,7 @@ pub trait MachBackend {
fn isa_flags(&self) -> Vec<settings::Value>;
/// Return triple for this backend.
fn triple(&self) -> Triple;
fn triple(&self) -> &Triple;
/// Return name for this backend.
fn name(&self) -> &'static str;