From cf1705c1d96b549ef5887a2bc3038dbc31912e50 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 7 Jun 2023 15:41:01 -0300 Subject: Captures point to string positions using indices That uses 4 bytes (uint) instead of 8 (char*); the size of the structure 'Capture' reduces from 16 to 8 bytes in 64-bit machines. --- lpcap.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lpcap.h') diff --git a/lpcap.h b/lpcap.h index e72d913..7cf8c24 100644 --- a/lpcap.h +++ b/lpcap.h @@ -27,8 +27,20 @@ typedef enum CapKind { } CapKind; +/* +** An unsigned integer large enough to index any subject entirely. +** It can be size_t, but that will double the size of the array +** of captures in a 64-bit machine. +*/ +#if !defined(Index_t) +typedef uint Index_t; +#endif + +#define MAXINDT (~(Index_t)0) + + typedef struct Capture { - const char *s; /* subject position */ + Index_t index; /* subject position */ unsigned short idx; /* extra info (group name, arg index, etc.) */ byte kind; /* kind of capture */ byte siz; /* size of full capture + 1 (0 = not a full capture) */ -- cgit v1.2.3-55-g6feb