allow inlining (this did not provide a statistically significant performance boost - oh well)
This commit is contained in:
@@ -274,6 +274,7 @@ impl ToString for Game {
|
||||
}
|
||||
|
||||
impl Game {
|
||||
#[inline]
|
||||
pub fn tile_ids(&self) -> Vec<u64> {
|
||||
self.tiles.iter().map(|tile| tile.id).collect()
|
||||
}
|
||||
@@ -281,6 +282,7 @@ impl Game {
|
||||
/// first available tile ID.
|
||||
/// e.g. if current tile IDs are [0, 2, 3] the result will be `1`
|
||||
/// if current tile IDs are [0, 1, 2] the result will be `3`
|
||||
#[inline]
|
||||
pub fn new_tile_id(&self) -> u64 {
|
||||
let mut new_id = 0;
|
||||
|
||||
@@ -299,6 +301,7 @@ impl Game {
|
||||
}
|
||||
|
||||
/// adds a tile safely and returns the new tile ID
|
||||
#[inline]
|
||||
pub fn add_tile(&mut self, mut tile: Tile) -> u64 {
|
||||
let new_id = self.new_tile_id();
|
||||
tile.id = new_id;
|
||||
@@ -306,6 +309,7 @@ impl Game {
|
||||
new_id
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn version_line(&self) -> String {
|
||||
if self.version.is_some() {
|
||||
format!(
|
||||
@@ -317,6 +321,7 @@ impl Game {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn room_format_line(&self) -> String {
|
||||
if self.room_format.is_some() {
|
||||
format!("\n\n! ROOM_FORMAT {}", self.room_format.unwrap().to_string())
|
||||
@@ -325,6 +330,7 @@ impl Game {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn font_line(&self) -> String {
|
||||
if self.font == Font::AsciiSmall {
|
||||
"".to_string()
|
||||
@@ -337,6 +343,7 @@ impl Game {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn text_direction_line(&self) -> &str {
|
||||
if self.text_direction == TextDirection::RightToLeft {
|
||||
"\n\nTEXT_DIRECTION RTL"
|
||||
@@ -346,11 +353,13 @@ impl Game {
|
||||
}
|
||||
|
||||
/// older bitsy games do not specify a version, but we can infer 1.0
|
||||
#[inline]
|
||||
pub fn version(&self) -> Version {
|
||||
self.version.unwrap_or(Version { major: 1, minor: 0 })
|
||||
}
|
||||
|
||||
/// older bitsy games do not specify a room format, but we can infer 0
|
||||
#[inline]
|
||||
pub fn room_format(&self) -> RoomFormat {
|
||||
self.room_format.unwrap_or(RoomFormat::Contiguous)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user