mirror of
https://github.com/lua/lua
synced 2025-04-15 01:12:54 +03:00
small optimization for local declarations without initializations
This commit is contained in:
parent
ede19c9138
commit
5dbb870815
21
lcode.c
21
lcode.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lcode.c,v 2.15 2005/08/17 18:32:09 roberto Exp $
|
** $Id: lcode.c,v 2.16 2005/08/29 20:49:21 roberto Exp roberto $
|
||||||
** Code generator for Lua
|
** Code generator for Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -29,14 +29,17 @@
|
|||||||
|
|
||||||
void luaK_nil (FuncState *fs, int from, int n) {
|
void luaK_nil (FuncState *fs, int from, int n) {
|
||||||
Instruction *previous;
|
Instruction *previous;
|
||||||
if (fs->pc > fs->lasttarget && /* no jumps to current position? */
|
if (fs->pc > fs->lasttarget) { /* no jumps to current position? */
|
||||||
GET_OPCODE(*(previous = &fs->f->code[fs->pc-1])) == OP_LOADNIL) {
|
if (fs->pc == 0) /* function start? */
|
||||||
int pfrom = GETARG_A(*previous);
|
return; /* positions are already clean */
|
||||||
int pto = GETARG_B(*previous);
|
if (GET_OPCODE(*(previous = &fs->f->code[fs->pc-1])) == OP_LOADNIL) {
|
||||||
if (pfrom <= from && from <= pto+1) { /* can connect both? */
|
int pfrom = GETARG_A(*previous);
|
||||||
if (from+n-1 > pto)
|
int pto = GETARG_B(*previous);
|
||||||
SETARG_B(*previous, from+n-1);
|
if (pfrom <= from && from <= pto+1) { /* can connect both? */
|
||||||
return;
|
if (from+n-1 > pto)
|
||||||
|
SETARG_B(*previous, from+n-1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */
|
luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user