lua-users home
lua-l archive

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


> IMHO the patch is wrong. One needs to check that the assigned
> variable is a new one and not a parameter. Only then can the
> first LOADNILs be omitted. But this requires restructuring ...

What do you mean by "restructuring"? It seems that an "if" (and an
"else" around the old code) is enough, is it not?

void luaK_nil (FuncState *fs, int from, int n) {
  Instruction *previous;
  if (fs->pc > fs->lasttarget) {  /* no jumps to current position? */
    if (fs->pc == 0) {  /* function start? */
      if (from >= fs->nactvar)
        return;  /* positions are already clean */
    }
    else {
      previous = &fs->f->code[fs->pc-1];
      ...

(BTW, I agree that we should scrap this optimization in the next
version.)

-- Roberto