danielpclark / faster_path

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

Add FasterPath.has_trailing_separator? #50

Closed mble closed 8 years ago

mble commented 8 years ago

https://github.com/danielpclark/faster_path/issues/49

mble commented 8 years ago

Benchmark stats

bench_rust_has_trailing_separator        0.197158        0.202823        0.194915        0.194807        0.222356
 PASS (1.05s) :: bench_rust_has_trailing_separator
bench_ruby_has_trailing_separator        0.330775        0.326297        0.353363        0.319253        0.323238
 PASS (1.69s) :: bench_ruby_has_trailing_separator
danielpclark commented 8 years ago

Excellent! New policy. Our methods can't blow up when they get handed a nil. Add a nil test and change the assert!(!string.is_null()); in the unsafe block to:

if string.is_null() {
  return false;
}
mble commented 8 years ago

@danielpclark Makes sense, all done. Added a sort of redundant test around nil, as rust will panic if it isn't properly handled. More there as a reminder.

mble commented 8 years ago

@danielpclark Done.