igorlira / dirplayer-rs

A web-compatible Shockwave Player emulator written in Rust
GNU General Public License v3.0
50 stars 10 forks source link

Delimiter as `char` #22

Closed ThisAccountHasBeenSuspended closed 3 months ago

ThisAccountHasBeenSuspended commented 3 months ago

My first PR with my new account on GitHub. Older PR from me: https://github.com/igorlira/dirplayer-rs/pull/5 https://github.com/igorlira/dirplayer-rs/pull/7 https://github.com/igorlira/dirplayer-rs/pull/8

The delimiter should only have a single char.

This avoids unnecessary calls from the processor and saves memory space (a String has a size of 24 bytes while a simple char has a size of 1 byte).

Compare String's

if delimiter == "\r" { }

lea     rdi, [rsp + 16]
lea     rsi, [rip + .L__unnamed_13]
call    qword ptr [rip + core::cmp::impls::<impl core::cmp::PartialEq<&B> for &A>::eq::h5252a21b9e880e82@GOTPCREL]
test    al, 1
jne     .LBB30_2

Compare char's

if delimiter == '\r' { }

cmp     al, 13
je      .LBB31_2