aboutsummaryrefslogtreecommitdiff
path: root/pattern.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2022-05-12 12:11:28 -0400
committerBruce Hill <bruce@bruce-hill.com>2022-05-12 12:11:28 -0400
commit56da250d69615d70774dbc361fa2693cca1e3df4 (patch)
treedbdeb2be018c5f10c13f721965b3bebff2283e88 /pattern.c
parente484a888151460ffc25a8478d9a9c9836652a35c (diff)
Split backref/named captures into separate concepts for performance
reasons.
Diffstat (limited to 'pattern.c')
-rw-r--r--pattern.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/pattern.c b/pattern.c
index 53970ac..edd007d 100644
--- a/pattern.c
+++ b/pattern.c
@@ -479,7 +479,13 @@ static pat_t *_bp_simplepattern(const char *str, const char *end, bool inside_st
size_t namelen = 0;
const char *a = after_name(str, end);
const char *eq = a;
- if (a > str && !matchstr(&eq, "=>", false, end) && matchchar(&eq, '=', false, end)) {
+ bool backreffable = false;
+ if (a > str && matchchar(&eq, ':', false, end)) {
+ name = str;
+ namelen = (size_t)(a-str);
+ str = eq;
+ backreffable = true;
+ } else if (a > str && !matchstr(&eq, "=>", false, end) && matchchar(&eq, '=', false, end)) {
name = str;
namelen = (size_t)(a-str);
str = eq;
@@ -492,6 +498,7 @@ static pat_t *_bp_simplepattern(const char *str, const char *end, bool inside_st
capture->args.capture.capture_pat = pat;
capture->args.capture.name = name;
capture->args.capture.namelen = namelen;
+ capture->args.capture.backreffable = backreffable;
return capture;
}
// Start of file/line