danielpclark / faster_path

Faster Pathname handling for Ruby written in Rust
MIT License
781 stars 29 forks source link

Refactor unsafe blocks #129

Closed danielpclark closed 6 years ago

danielpclark commented 6 years ago

The unsafe blocks are a bit worrisome, it does not inspire confidence, after all, the idea to use Rust instead of C is that it can ensure memory management safety.

Saying that(without a suggestion probably would of not mentioned it), I offer a suggestion: https://docs.rs/memchr/2/memchr/fn.memrchr.html (this is also used by ripgrep, also, perf benchmarks: https://github.com/BurntSushi/rust-memchr#performance — Lilian A. Moraru

danielpclark commented 6 years ago

@glebm Only one unsafe left https://github.com/danielpclark/faster_path/blob/0d74190590e40ba3e380742d3c17865913ba8ccf/src/path_parsing.rs#L28 Do you think this is a good candidate for refactoring with memchr/memrchr?

glebm commented 6 years ago

Memchr functions find the first/last matching character, this finds the last non-matching character.