use i16 for coordinates instead of isize, yielding better cache locality etc

This commit is contained in:
Crispy 2024-12-07 20:49:23 +01:00
parent 28213da9f3
commit 42a355d387
3 changed files with 18 additions and 15 deletions

View file

@ -2,10 +2,12 @@ use std::ops::Add;
use raylib::prelude::*;
pub type PosInt = i16;
#[derive(Debug, Default, Clone, Copy, PartialEq)]
pub struct Pos {
pub x: isize,
pub y: isize,
pub x: PosInt,
pub y: PosInt,
}
impl Pos {
@ -34,8 +36,8 @@ impl Pos {
impl From<(usize, usize)> for Pos {
fn from(value: (usize, usize)) -> Self {
Self {
x: value.0 as isize,
y: value.1 as isize,
x: value.0 as PosInt,
y: value.1 as PosInt,
}
}
}
@ -43,8 +45,8 @@ impl From<(usize, usize)> for Pos {
impl From<(i32, i32)> for Pos {
fn from(value: (i32, i32)) -> Self {
Self {
x: value.0 as isize,
y: value.1 as isize,
x: value.0 as PosInt,
y: value.1 as PosInt,
}
}
}
@ -52,8 +54,8 @@ impl From<(i32, i32)> for Pos {
impl From<Vector2> for Pos {
fn from(vec: Vector2) -> Self {
Self {
x: vec.x as isize,
y: vec.y as isize,
x: vec.x as PosInt,
y: vec.y as PosInt,
}
}
}