Re:The Rust Performance Book
by gameswithgo on Tuesday November 17, 2020 @09:03AM
(#25123812)
when iterators can’t be used and llvm can’t elide you can use unsafe to elide by hand. the scenarios where the performance matters and iterators can’t be used are thankfully pretty rare so not much unsafe has to be used for this reason.
[ Parent
| on HN ]
Is there any way to treat bounds check as a warning to eliminate it early?
Re:The Rust Performance Book
by staticassertion on Saturday November 21, 2020 @06:42PM
(#25173580)
A nice method I've found (and seems popular) is to use unsafe but use a debug_assert!. That way your tests will fail loudly if you hit the assertion, but you won't take a hit in production.
Re:The Rust Performance Book
by gameswithgo on Tuesday November 17, 2020 @09:25AM
(#25124032)
not globally no. isolating that kind of behavior to unsafe blocks is a priority to make it easier to audit. if you wanted globally unsafe memory C or Zig would be a more sensible choice