Lua 5.4.2 (src/lundump.c) LoadProtos, remove loop initialization

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Lua 5.4.2 (src/lundump.c) LoadProtos, remove loop initialization

Ranier Vilela-2
Hi,

I think that it is possible to safely remove the initialization loop from the loadProtos function.
Because the same array will be overwritten in the next loop, in the same positions.

Is this correct?

regards,
Ranier Vilela

avoid_redundant_loop_lundump.patch (726 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Lua 5.4.2 (src/lundump.c) LoadProtos, remove loop initialization

Luiz Henrique de Figueiredo
> I think that it is possible to safely remove the initialization loop from the loadProtos function.
> Because the same array will be overwritten in the next loop, in the same positions.
>
> Is this correct?

No, it is not. The call to luaF_newproto in the next loop may raise
errors and f->p needs to be in a consistent state. The comments in the
loops in  loadUpvalues also apply to loadProtos.

I don't mean to be harsh and we do welcome suggestions and
corrections, but do you really think we write useless code?
Reply | Threaded
Open this post in threaded view
|

Re: Lua 5.4.2 (src/lundump.c) LoadProtos, remove loop initialization

Ranier Vilela-2
Em ter., 10 de nov. de 2020 às 15:46, Luiz Henrique de Figueiredo <[hidden email]> escreveu:
> I think that it is possible to safely remove the initialization loop from the loadProtos function.
> Because the same array will be overwritten in the next loop, in the same positions.
>
> Is this correct?

No, it is not. The call to luaF_newproto in the next loop may raise
errors and f->p needs to be in a consistent state. The comments in the
loops in  loadUpvalues also apply to loadProtos.

I don't mean to be harsh and we do welcome suggestions and
corrections, but do you really think we write useless code?
Am I bothering you?
Reply | Threaded
Open this post in threaded view
|

Re: Lua 5.4.2 (src/lundump.c) LoadProtos, remove loop initialization

Roberto Ierusalimschy
> > I don't mean to be harsh and we do welcome suggestions and
> > corrections, but do you really think we write useless code?
> >
> Am I bothering you?

I think it is a problem of tone. When you see some code that you
don't understand, you assume it is wrong and immediately suggest a
"correction". Instead, you should assume that there are things you may
not understand, and ask why that code is the way it is.

-- Roberto
Reply | Threaded
Open this post in threaded view
|

Re: Lua 5.4.2 (src/lundump.c) LoadProtos, remove loop initialization

Ranier Vilela-2
Em qua., 11 de nov. de 2020 às 10:22, Roberto Ierusalimschy <[hidden email]> escreveu:
> > I don't mean to be harsh and we do welcome suggestions and
> > corrections, but do you really think we write useless code?
> >
> Am I bothering you?

I think it is a problem of tone. When you see some code that you
don't understand, you assume it is wrong and immediately suggest a
"correction". Instead, you should assume that there are things you may
not understand, and ask why that code is the way it is.
Ok, of course I can.
I really don't know anything about Lua.
But when I make a suggestion, it doesn't mean that I'm "stating" that it should be accepted.
But that I am accelerating a little, proposing a solution, even if wrong, that should be promptly rejected.
The problem is that most of the time, it takes forever, even when the solution is good and correct.
Contributing is necessary to find time, rare and scarce time.

Ranier Vilela
Reply | Threaded
Open this post in threaded view
|

Re: Lua 5.4.2 (src/lundump.c) LoadProtos, remove loop initialization

Coda Highland


On Wed, Nov 11, 2020 at 7:45 AM Ranier Vilela <[hidden email]> wrote:
Em qua., 11 de nov. de 2020 às 10:22, Roberto Ierusalimschy <[hidden email]> escreveu:
> > I don't mean to be harsh and we do welcome suggestions and
> > corrections, but do you really think we write useless code?
> >
> Am I bothering you?

I think it is a problem of tone. When you see some code that you
don't understand, you assume it is wrong and immediately suggest a
"correction". Instead, you should assume that there are things you may
not understand, and ask why that code is the way it is.
Ok, of course I can.
I really don't know anything about Lua.
But when I make a suggestion, it doesn't mean that I'm "stating" that it should be accepted.
But that I am accelerating a little, proposing a solution, even if wrong, that should be promptly rejected.
The problem is that most of the time, it takes forever, even when the solution is good and correct.
Contributing is necessary to find time, rare and scarce time.

Ranier Vilela

I think there's a bit of a language barrier to note here.

Ranier, I believe you have good intentions, and I can see that's how you were trying to approach it. Unfortunately, the way your phrasing comes across in English isn't being received with the tone you intended. Roberto's suggestion is that you would be taken with a better attitude if you asked the question "Why is it this way?" instead of saying "I think it should be different." You aren't wrong about time being scarce: the Lua developers' time is also scarce. So when they have to read through the mailing list, it can help to take a moment of your own time to make sure your messages will be read in the right way.

For example, in this thread, you could have said something like "I see that loadProtos initializes the array before entering the loop, but it looks like it gets overwritten right away. Why is the code written this way? Could it be optimized?" That would have seemed like a more positive approach.

/s/ Adam