From 9bccc0d50d1ffa4cd12a3c3ecaa5403aef360bed Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Tue, 28 Apr 2020 16:39:51 +0200 Subject: more inlining --- src/lib.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index d53e5fe..82ecf7e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -370,6 +370,7 @@ impl Agent { impl Agent { /// Unconditionally change the tagged type. + #[inline] fn transmute(&self) -> &Agent { // Beware, unsafe code ahead! // @@ -405,11 +406,13 @@ impl Agent { } /// Erase any extra information about the contained agent kind. + #[inline] pub fn erase(&self) -> &Agent { self.transmute() } /// Try to convert this `Agent` to an `Agent` representing a `Player`. + #[inline] pub fn as_player(&self) -> Option<&Agent> { if self.kind.is_player() { Some(self.transmute()) @@ -419,6 +422,7 @@ impl Agent { } /// Try to convert this `Agent` to an `Agent` representing a `Gadget`. + #[inline] pub fn as_gadget(&self) -> Option<&Agent> { if self.kind.is_gadget() { Some(self.transmute()) @@ -428,6 +432,7 @@ impl Agent { } /// Try to convert this `Agent` to an `Agent` representing a `Character`. + #[inline] pub fn as_character(&self) -> Option<&Agent> { if self.kind.is_character() { Some(self.transmute()) @@ -439,31 +444,37 @@ impl Agent { impl Agent { /// Directly access the underlying player data. + #[inline] pub fn player(&self) -> &Player { self.kind.as_player().expect("Agent had no player!") } /// Shorthand to get the player's account name. + #[inline] pub fn account_name(&self) -> &str { self.player().account_name() } /// Shorthand to get the player's character name. + #[inline] pub fn character_name(&self) -> &str { self.player().character_name() } /// Shorthand to get the player's elite specialization. + #[inline] pub fn elite(&self) -> Option { self.player().elite() } /// Shorthand to get the player's profession. + #[inline] pub fn profession(&self) -> Profession { self.player().profession() } /// Shorthand to get the player's subgroup. + #[inline] pub fn subgroup(&self) -> u8 { self.player().subgroup() } @@ -471,16 +482,19 @@ impl Agent { impl Agent { /// Directly access the underlying gadget data. + #[inline] pub fn gadget(&self) -> &Gadget { self.kind.as_gadget().expect("Agent had no gadget!") } /// Shorthand to get the gadget's id. + #[inline] pub fn id(&self) -> u16 { self.gadget().id() } /// Shorthand to get the gadget's name. + #[inline] pub fn name(&self) -> &str { self.gadget().name() } @@ -488,6 +502,7 @@ impl Agent { impl Agent { /// Directly access the underlying character data. + #[inline] pub fn character(&self) -> &Character { self.kind .as_character() @@ -495,11 +510,13 @@ impl Agent { } /// Shorthand to get the character's id. + #[inline] pub fn id(&self) -> u16 { self.character().id() } /// Shorthand to get the character's name. + #[inline] pub fn name(&self) -> &str { self.character().name() } @@ -515,6 +532,7 @@ pub struct Log { impl Log { /// Return all agents present in this log. + #[inline] pub fn agents(&self) -> &[Agent] { &self.agents } @@ -581,6 +599,7 @@ impl Log { } /// Returns the encounter id. + #[inline] pub fn encounter_id(&self) -> u16 { self.boss_id } @@ -590,11 +609,13 @@ impl Log { /// Some logs don't have an encounter set or have an ID that is unknown to us (for example, if /// people set up arcdps with custom IDs). Therefore, this method can only return the encounter /// if we know about it in [`Boss`][Boss]. + #[inline] pub fn encounter(&self) -> Option { Boss::from_u16(self.boss_id) } /// Return all events present in this log. + #[inline] pub fn events(&self) -> &[Event] { &self.events } -- cgit v1.2.3