Skip to content

Commit bb54959

Browse files
committed
Inline LValue::from and LObject::from
1 parent 9bfbb8a commit bb54959

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/logic/vm/variables.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ impl<T> From<T> for LValue
365365
where
366366
T: AsPrimitive<f64> + Numeric,
367367
{
368+
#[inline]
368369
fn from(value: T) -> Self {
369370
let value = value.as_();
370371
if Self::valid(value) {
@@ -379,12 +380,14 @@ where
379380
}
380381

381382
impl From<bool> for LValue {
383+
#[inline]
382384
fn from(value: bool) -> Self {
383385
(if value { 1. } else { 0. }).into()
384386
}
385387
}
386388

387389
impl From<LObject> for LValue {
390+
#[inline]
388391
fn from(value: LObject) -> Self {
389392
if value == LObject::Null {
390393
Self::NULL
@@ -395,48 +398,56 @@ impl From<LObject> for LValue {
395398
}
396399

397400
impl From<LString> for LValue {
401+
#[inline]
398402
fn from(value: LString) -> Self {
399403
unsafe { Self::non_null(LObject::String(value)) }
400404
}
401405
}
402406

403407
impl From<Rc<U16Str>> for LValue {
408+
#[inline]
404409
fn from(value: Rc<U16Str>) -> Self {
405410
LString::Rc(value).into()
406411
}
407412
}
408413

409414
impl From<&'static U16Str> for LValue {
415+
#[inline]
410416
fn from(value: &'static U16Str) -> Self {
411417
LString::Static(value).into()
412418
}
413419
}
414420

415421
impl From<String> for LValue {
422+
#[inline]
416423
fn from(value: String) -> Self {
417424
LString::rc(U16String::from_str(&value).as_ustr()).into()
418425
}
419426
}
420427

421428
impl From<Content> for LValue {
429+
#[inline]
422430
fn from(value: Content) -> Self {
423431
unsafe { Self::non_null(LObject::Content(value)) }
424432
}
425433
}
426434

427435
impl From<Team> for LValue {
436+
#[inline]
428437
fn from(value: Team) -> Self {
429438
unsafe { Self::non_null(LObject::Team(value)) }
430439
}
431440
}
432441

433442
impl From<Building> for LValue {
443+
#[inline]
434444
fn from(value: Building) -> Self {
435445
unsafe { Self::non_null(LObject::Building(value)) }
436446
}
437447
}
438448

439449
impl From<LAccess> for LValue {
450+
#[inline]
440451
fn from(value: LAccess) -> Self {
441452
unsafe { Self::non_null(LObject::Sensor(value)) }
442453
}
@@ -446,6 +457,7 @@ impl<T> From<Option<T>> for LValue
446457
where
447458
LValue: From<T>,
448459
{
460+
#[inline]
449461
fn from(value: Option<T>) -> Self {
450462
match value {
451463
Some(value) => value.into(),
@@ -471,30 +483,35 @@ impl Default for LObject {
471483
}
472484

473485
impl From<LString> for LObject {
486+
#[inline]
474487
fn from(value: LString) -> Self {
475488
Self::String(value)
476489
}
477490
}
478491

479492
impl From<Content> for LObject {
493+
#[inline]
480494
fn from(value: Content) -> Self {
481495
Self::Content(value)
482496
}
483497
}
484498

485499
impl From<Team> for LObject {
500+
#[inline]
486501
fn from(value: Team) -> Self {
487502
Self::Team(value)
488503
}
489504
}
490505

491506
impl From<Building> for LObject {
507+
#[inline]
492508
fn from(value: Building) -> Self {
493509
Self::Building(value)
494510
}
495511
}
496512

497513
impl From<LAccess> for LObject {
514+
#[inline]
498515
fn from(value: LAccess) -> Self {
499516
Self::Sensor(value)
500517
}
@@ -504,6 +521,7 @@ impl<T> From<Option<T>> for LObject
504521
where
505522
LObject: From<T>,
506523
{
524+
#[inline]
507525
fn from(value: Option<T>) -> Self {
508526
match value {
509527
Some(value) => value.into(),

0 commit comments

Comments
 (0)