Standard way to supply hints to branches
Daniel N
no at public.email
Sat Sep 7 20:51:25 UTC 2024
On Thursday, 29 August 2024 at 18:28:04 UTC, Walter Bright wrote:
> On 8/28/2024 2:45 AM, Manu wrote:
>> Here's one that I just wrote a short while ago:
>> https://gist.github.com/TurkeyMan/0e49da245cc0086f852ac18deed21a9c
>
>
> ```
> if (data.length < 4) // unlikely
> return 0;
> ```
>
> replace with:
>
> ```
> if (data.length < 4)
> goto Lreturn0;
> ```
This seldom works.
onlineapp.d(4): Error: `goto` skips declaration of variable
`onlineapp.fun.y`
onlineapp.d(6): declared here
```
int fun(int x)
{
if (x < 0)
goto Lreturn0;
int y = x * x;
return y;
Lreturn0:
return 0;
}
```
More information about the Digitalmars-d
mailing list