On Wed, 28 Aug 2024 at 07:26, Walter Bright via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
On 8/26/2024 10:39 PM, Manu wrote:
> Your suggestions could appear in almost every single at-least-warm function, and
> it's not clear how they marry with eachother. We discussed 2 principle cases;
> likely early return because of short-path or cached value, and unlikely early
> return due to argument validation failure. Plenty of functions contain both
> cases, and plenty of functions contain numerous such items.
> Try and imagine how your suggestion scales when there are 4-5 conditions that
> need to be tested on function entry, and they don't all receive the same hint. I
> value readable and maintainable code...

For reference, a real world example of your code?

Here's one that I just wrote a short while ago:
https://gist.github.com/TurkeyMan/0e49da245cc0086f852ac18deed21a9c

This function can be very hot; called once for every byte in a byte stream when sifting for a signal in a noisy transmission environment.
There are 4-5 guaranteed mispredictions in the nominal path in lieu of hints...