diff options
author | Paul Wankadia <junyer@google.com> | 2018-12-24 05:13:27 -0800 |
---|---|---|
committer | Paul Wankadia <junyer@google.com> | 2018-12-24 13:14:42 +0000 |
commit | 2cf86e5ab6dcfe045a1f510c2b9a8b012a4158cd (patch) | |
tree | 033cf8381face0defe134b713d096cbff0013dde /re2/re2.h | |
parent | ec379c1e3349b48260a3f9f5876567dff07d83b9 (diff) | |
download | regex-re2-2cf86e5ab6dcfe045a1f510c2b9a8b012a4158cd.tar.gz |
Compute num_captures_ eagerly.
Change-Id: I7f77eece4c553956e61c746a77c72e095fb1d0e5
Reviewed-on: https://code-review.googlesource.com/c/36874
Reviewed-by: Paul Wankadia <junyer@google.com>
Diffstat (limited to 're2/re2.h')
-rw-r--r-- | re2/re2.h | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -479,7 +479,7 @@ class RE2 { // Return the number of capturing subpatterns, or -1 if the // regexp wasn't valid on construction. The overall match ($0) // does not count: if the regexp is "(a)(b)", returns 2. - int NumberOfCapturingGroups() const; + int NumberOfCapturingGroups() const { return num_captures_; } // Return a map from names to capturing indices. // The map records the index of the leftmost group @@ -744,6 +744,7 @@ class RE2 { re2::Regexp* entire_regexp_; // parsed regular expression re2::Regexp* suffix_regexp_; // parsed regular expression, prefix removed re2::Prog* prog_; // compiled program for regexp + int num_captures_; // Number of capturing groups bool is_one_pass_; // can use prog_->SearchOnePass? mutable re2::Prog* rprog_; // reverse program for regexp @@ -751,7 +752,6 @@ class RE2 { // (or points to empty string) mutable ErrorCode error_code_; // Error code mutable string error_arg_; // Fragment of regexp showing error - mutable int num_captures_; // Number of capturing groups // Map from capture names to indices mutable const std::map<string, int>* named_groups_; @@ -761,7 +761,6 @@ class RE2 { // Onces for lazy computations. mutable std::once_flag rprog_once_; - mutable std::once_flag num_captures_once_; mutable std::once_flag named_groups_once_; mutable std::once_flag group_names_once_; |