From 44fab2a44d06a956c3121ceba2b39ca7b00dc428 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 29 May 2023 09:39:03 -0300 Subject: Code size stored in code itself Most patterns do not have code, as they are not directly used for a match; they are created only to compose larger patterns. So, we shouldn't waste space to store the size of their code, as a NULL pointer already indicates that the size is zero. --- lpvm.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lpvm.h') diff --git a/lpvm.h b/lpvm.h index a64d577..684f0c9 100644 --- a/lpvm.h +++ b/lpvm.h @@ -43,7 +43,11 @@ typedef enum Opcode { } Opcode; - +/* +** All array of instructions has a 'codesize' as its first element +** and is referred by a pointer to its second element, which is the +** first actual opcode. +*/ typedef union Instruction { struct Inst { byte code; @@ -57,6 +61,7 @@ typedef union Instruction { } aux2; } i; int offset; + uint codesize; byte buff[1]; } Instruction; @@ -66,7 +71,6 @@ typedef union Instruction { int charinset (const Instruction *i, const byte *buff, uint c); -void printpatt (Instruction *p, int n); const char *match (lua_State *L, const char *o, const char *s, const char *e, Instruction *op, Capture *capture, int ptop); -- cgit v1.2.3-55-g6feb