lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, May 20, 2020 at 3:12 AM Massimo Sala <massimo.sala.71@gmail.com> wrote:
>
> file ldo.c, function rethook, starting at line 337/340:
>
>> if (globalhook || (L->hookmask & LUA_MASKRET)) { /* is return hook on? */
>> ...
>>   luaD_hook(L, globalhook, LUA_HOOKRET, -1, ftransfer, nres); /* call it */
>>   if (L->hookmask & LUA_MASKRET)
>>      luaD_hook(L, L->hook, LUA_HOOKRET, -1, ftransfer, nres); /* call it */
>
>
>
> Looking at the indentation and the previous test,
> I expected the globalhook is called this way:
>
>>   if (globalhook)
>>      luaD_hook(L, globalhook, LUA_HOOKRET, -1, ftransfer, nres); /* call it */
>

The first "if" in my patch is just for efficiency, to avoid setting up
for the hooks if neither will be called. Testing for globalhook later
isn't necessary here, since luaD_hook does that itself. The reason
that the regular hook still needs "if (L->hookmask & LUA_MASKRET)" is
that it's testing the mask rather than the function, and luaD_hook
only tests the function.

Joseph C. Sible