diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-06-07 15:41:01 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-06-07 15:41:01 -0300 |
commit | cf1705c1d96b549ef5887a2bc3038dbc31912e50 (patch) | |
tree | 98d37b61c4f095b089fa40e55032e0479932be6c /lpcap.h | |
parent | e31e13f59ef1a4df1698b15ff1fe0198553cc3c2 (diff) | |
download | lpeg-cf1705c1d96b549ef5887a2bc3038dbc31912e50.tar.gz lpeg-cf1705c1d96b549ef5887a2bc3038dbc31912e50.tar.bz2 lpeg-cf1705c1d96b549ef5887a2bc3038dbc31912e50.zip |
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.
Diffstat (limited to 'lpcap.h')
-rw-r--r-- | lpcap.h | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -27,8 +27,20 @@ typedef enum CapKind { | |||
27 | } CapKind; | 27 | } CapKind; |
28 | 28 | ||
29 | 29 | ||
30 | /* | ||
31 | ** An unsigned integer large enough to index any subject entirely. | ||
32 | ** It can be size_t, but that will double the size of the array | ||
33 | ** of captures in a 64-bit machine. | ||
34 | */ | ||
35 | #if !defined(Index_t) | ||
36 | typedef uint Index_t; | ||
37 | #endif | ||
38 | |||
39 | #define MAXINDT (~(Index_t)0) | ||
40 | |||
41 | |||
30 | typedef struct Capture { | 42 | typedef struct Capture { |
31 | const char *s; /* subject position */ | 43 | Index_t index; /* subject position */ |
32 | unsigned short idx; /* extra info (group name, arg index, etc.) */ | 44 | unsigned short idx; /* extra info (group name, arg index, etc.) */ |
33 | byte kind; /* kind of capture */ | 45 | byte kind; /* kind of capture */ |
34 | byte siz; /* size of full capture + 1 (0 = not a full capture) */ | 46 | byte siz; /* size of full capture + 1 (0 = not a full capture) */ |