remove inlining

This commit is contained in:
2020-07-19 08:42:03 +01:00
parent 3de82cbacc
commit f08f0fdc16
16 changed files with 1 additions and 84 deletions

View File

@@ -35,7 +35,6 @@ impl RoomFormat {
pub enum RoomType {Room, Set}
impl ToString for RoomType {
#[inline]
fn to_string(&self) -> String {
match &self {
RoomType::Set => "SET",
@@ -54,7 +53,6 @@ pub struct Version {
pub struct InvalidVersion;
impl Version {
#[inline]
fn from(str: &str) -> Result<Version, InvalidVersion> {
let parts: Vec<&str> = str.split(".").collect();
if parts.len() == 2 {
@@ -102,7 +100,6 @@ pub struct GameHasNoAvatar;
// todo no tiles? no rooms? no palettes? turn this into an enum?
impl Game {
#[inline]
pub fn from(string: String) -> Result<Game, NotFound> {
let line_endings_crlf = string.contains("\r\n");
let mut string = string;
@@ -243,7 +240,6 @@ impl Game {
}
/// todo refactor this into "get T by ID", taking a Vec<T> and an ID name?
#[inline]
pub fn get_sprite_by_id(&self, id: String) -> Result<&Sprite, NotFound> {
let index = self.sprites.iter().position(
|sprite| sprite.id == id
@@ -525,7 +521,6 @@ impl Game {
}
impl ToString for Game {
#[inline]
fn to_string(&self) -> String {
let mut segments: Vec<String> = Vec::new();
@@ -585,43 +580,33 @@ impl ToString for Game {
impl Game {
// todo dedupe
#[inline]
pub fn palette_ids(&self) -> Vec<String> {
self.palettes.iter().map(|palette| palette.id.clone()).collect()
}
#[inline]
pub fn tile_ids(&self) -> Vec<String> {
self.tiles.iter().map(|tile| tile.id.clone()).collect()
}
#[inline]
pub fn sprite_ids(&self) -> Vec<String> {
self.sprites.iter().map(|sprite| sprite.id.clone()).collect()
}
#[inline]
pub fn room_ids(&self) -> Vec<String> {
self.rooms.iter().map(|room| room.id.clone()).collect()
}
#[inline]
pub fn item_ids(&self) -> Vec<String> {
self.items.iter().map(|item| item.id.clone()).collect()
}
#[inline]
pub fn dialogue_ids(&self) -> Vec<String> {
self.dialogues.iter().map(|dialogue| dialogue.id.clone()).collect()
}
#[inline]
pub fn ending_ids(&self) -> Vec<String> {
self.endings.iter().map(|ending| ending.id.clone()).collect()
}
#[inline]
pub fn variable_ids(&self) -> Vec<String> {
self.variables.iter().map(|variable| variable.id.clone()).collect()
}
@@ -635,7 +620,6 @@ 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) -> String {
let mut ids = self.tile_ids();
// don't allow 0 - this is a reserved ID for an implicit background tile
@@ -679,7 +663,6 @@ impl Game {
}
/// adds a palette safely and returns the ID
#[inline]
pub fn add_palette(&mut self, mut palette: Palette) -> String {
let new_id = try_id(&self.palette_ids(), &palette.id);
if new_id != palette.id {
@@ -690,7 +673,6 @@ impl Game {
}
/// adds a tile safely and returns the ID
#[inline]
pub fn add_tile(&mut self, mut tile: Tile) -> String {
if tile.id == "0".to_string() || self.tile_ids().contains(&tile.id) {
let new_id = self.new_tile_id();
@@ -704,7 +686,6 @@ impl Game {
}
/// adds a sprite safely and returns the ID
#[inline]
pub fn add_sprite(&mut self, mut sprite: Sprite) -> String {
let new_id = try_id(&self.sprite_ids(), &sprite.id);
if new_id != sprite.id {
@@ -715,7 +696,6 @@ impl Game {
}
/// adds an item safely and returns the ID
#[inline]
pub fn add_item(&mut self, mut item: Item) -> String {
let new_id = try_id(&self.item_ids(), &item.id);
if new_id != item.id {
@@ -726,7 +706,6 @@ impl Game {
}
/// adds a dialogue safely and returns the ID
#[inline]
pub fn add_dialogue(&mut self, mut dialogue: Dialogue) -> String {
let new_id = try_id(&self.dialogue_ids(), &dialogue.id);
if new_id != dialogue.id {
@@ -798,7 +777,6 @@ impl Game {
self.tiles = unique_tiles;
}
#[inline]
fn version_line(&self) -> String {
if self.version.is_some() {
format!(
@@ -810,7 +788,6 @@ 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())
@@ -819,7 +796,6 @@ impl Game {
}
}
#[inline]
fn font_line(&self) -> String {
if self.font == Font::AsciiSmall {
"".to_string()
@@ -832,7 +808,6 @@ impl Game {
}
}
#[inline]
fn text_direction_line(&self) -> &str {
if self.text_direction == TextDirection::RightToLeft {
"\n\nTEXT_DIRECTION RTL"
@@ -842,13 +817,11 @@ 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)
}