Make MachBackend::triple return &Triple
This avoids an unnecessary clone
This commit is contained in:
@@ -98,8 +98,8 @@ impl MachBackend for AArch64Backend {
|
|||||||
"aarch64"
|
"aarch64"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn triple(&self) -> Triple {
|
fn triple(&self) -> &Triple {
|
||||||
self.triple.clone()
|
&self.triple
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flags(&self) -> &shared_settings::Flags {
|
fn flags(&self) -> &shared_settings::Flags {
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ impl MachBackend for Arm32Backend {
|
|||||||
"arm32"
|
"arm32"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn triple(&self) -> Triple {
|
fn triple(&self) -> &Triple {
|
||||||
self.triple.clone()
|
&self.triple
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flags(&self) -> &settings::Flags {
|
fn flags(&self) -> &settings::Flags {
|
||||||
|
|||||||
@@ -101,8 +101,8 @@ impl MachBackend for S390xBackend {
|
|||||||
"s390x"
|
"s390x"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn triple(&self) -> Triple {
|
fn triple(&self) -> &Triple {
|
||||||
self.triple.clone()
|
&self.triple
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flags(&self) -> &shared_settings::Flags {
|
fn flags(&self) -> &shared_settings::Flags {
|
||||||
|
|||||||
@@ -98,8 +98,8 @@ impl MachBackend for X64Backend {
|
|||||||
"x64"
|
"x64"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn triple(&self) -> Triple {
|
fn triple(&self) -> &Triple {
|
||||||
self.triple.clone()
|
&self.triple
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reg_universe(&self) -> &RealRegUniverse {
|
fn reg_universe(&self) -> &RealRegUniverse {
|
||||||
|
|||||||
@@ -14,16 +14,13 @@ use target_lexicon::Triple;
|
|||||||
/// A wrapper around a `MachBackend` that provides a `TargetIsa` impl.
|
/// A wrapper around a `MachBackend` that provides a `TargetIsa` impl.
|
||||||
pub struct TargetIsaAdapter {
|
pub struct TargetIsaAdapter {
|
||||||
backend: Box<dyn MachBackend + Send + Sync + 'static>,
|
backend: Box<dyn MachBackend + Send + Sync + 'static>,
|
||||||
triple: Triple,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TargetIsaAdapter {
|
impl TargetIsaAdapter {
|
||||||
/// Create a new `TargetIsa` wrapper around a `MachBackend`.
|
/// Create a new `TargetIsa` wrapper around a `MachBackend`.
|
||||||
pub fn new<B: MachBackend + Send + Sync + 'static>(backend: B) -> TargetIsaAdapter {
|
pub fn new<B: MachBackend + Send + Sync + 'static>(backend: B) -> TargetIsaAdapter {
|
||||||
let triple = backend.triple();
|
|
||||||
TargetIsaAdapter {
|
TargetIsaAdapter {
|
||||||
backend: Box::new(backend),
|
backend: Box::new(backend),
|
||||||
triple,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,7 +41,7 @@ impl TargetIsa for TargetIsaAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn triple(&self) -> &Triple {
|
fn triple(&self) -> &Triple {
|
||||||
&self.triple
|
self.backend.triple()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flags(&self) -> &Flags {
|
fn flags(&self) -> &Flags {
|
||||||
|
|||||||
@@ -390,7 +390,7 @@ pub trait MachBackend {
|
|||||||
fn isa_flags(&self) -> Vec<settings::Value>;
|
fn isa_flags(&self) -> Vec<settings::Value>;
|
||||||
|
|
||||||
/// Return triple for this backend.
|
/// Return triple for this backend.
|
||||||
fn triple(&self) -> Triple;
|
fn triple(&self) -> &Triple;
|
||||||
|
|
||||||
/// Return name for this backend.
|
/// Return name for this backend.
|
||||||
fn name(&self) -> &'static str;
|
fn name(&self) -> &'static str;
|
||||||
|
|||||||
Reference in New Issue
Block a user