re2 1.19.2 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/.github/actions/linux-alpine-node-16/Dockerfile +1 -1
  2. package/.github/actions/linux-alpine-node-18/Dockerfile +1 -1
  3. package/.github/actions/linux-alpine-node-20/Dockerfile +1 -1
  4. package/.gitmodules +5 -2
  5. package/README.md +1 -0
  6. package/binding.gyp +82 -25
  7. package/lib/replace.cc +4 -4
  8. package/package.json +1 -1
  9. package/tsconfig.json +2 -1
  10. package/vendor/re2/.bazelrc +16 -0
  11. package/vendor/re2/.github/bazel.sh +24 -0
  12. package/vendor/re2/.github/cmake.sh +12 -0
  13. package/vendor/re2/.github/workflows/ci-bazel.yml +17 -0
  14. package/vendor/re2/.github/workflows/ci-cmake.yml +108 -0
  15. package/vendor/re2/.github/workflows/ci.yml +89 -0
  16. package/vendor/re2/.github/workflows/pr.yml +26 -0
  17. package/vendor/re2/.github/workflows/python.yml +185 -0
  18. package/vendor/re2/AUTHORS +13 -0
  19. package/vendor/re2/BUILD.bazel +280 -0
  20. package/vendor/re2/CMakeLists.txt +268 -0
  21. package/vendor/re2/CONTRIBUTING.md +2 -0
  22. package/vendor/re2/CONTRIBUTORS +41 -0
  23. package/vendor/re2/Makefile +400 -0
  24. package/vendor/{README → re2/README} +5 -0
  25. package/vendor/re2/SECURITY.md +4 -0
  26. package/vendor/re2/WORKSPACE.bazel +62 -0
  27. package/vendor/re2/app/BUILD.bazel +19 -0
  28. package/vendor/re2/app/_re2.cc +94 -0
  29. package/vendor/re2/app/_re2.d.ts +23 -0
  30. package/vendor/re2/app/app.ts +111 -0
  31. package/vendor/re2/app/build.sh +50 -0
  32. package/vendor/re2/app/index.html +5 -0
  33. package/vendor/re2/app/package.json +14 -0
  34. package/vendor/re2/app/rollup.config.js +28 -0
  35. package/vendor/re2/app/tsconfig.json +17 -0
  36. package/vendor/re2/benchlog/benchplot.py +98 -0
  37. package/vendor/re2/benchlog/mktable +155 -0
  38. package/vendor/re2/doc/mksyntaxgo +42 -0
  39. package/vendor/re2/doc/mksyntaxhtml +42 -0
  40. package/vendor/re2/doc/mksyntaxwiki +36 -0
  41. package/vendor/re2/doc/syntax.html +477 -0
  42. package/vendor/re2/doc/syntax.txt +463 -0
  43. package/vendor/re2/lib/git/commit-msg.hook +104 -0
  44. package/vendor/re2/libre2.symbols +19 -0
  45. package/vendor/re2/libre2.symbols.darwin +15 -0
  46. package/vendor/re2/python/BUILD.bazel +36 -0
  47. package/vendor/re2/python/README +1 -0
  48. package/vendor/re2/python/_re2.cc +338 -0
  49. package/vendor/re2/python/re2.py +582 -0
  50. package/vendor/re2/python/re2_test.py +482 -0
  51. package/vendor/re2/python/setup.py +105 -0
  52. package/vendor/re2/{bitmap256.cc → re2/bitmap256.cc} +4 -4
  53. package/vendor/re2/{bitstate.cc → re2/bitstate.cc} +21 -25
  54. package/vendor/re2/{compile.cc → re2/compile.cc} +5 -4
  55. package/vendor/re2/{dfa.cc → re2/dfa.cc} +120 -101
  56. package/vendor/re2/{filtered_re2.cc → re2/filtered_re2.cc} +8 -11
  57. package/vendor/re2/{filtered_re2.h → re2/filtered_re2.h} +5 -4
  58. package/vendor/re2/{fuzzing → re2/fuzzing}/re2_fuzzer.cc +4 -6
  59. package/vendor/re2/{mimics_pcre.cc → re2/mimics_pcre.cc} +0 -1
  60. package/vendor/re2/{nfa.cc → re2/nfa.cc} +34 -37
  61. package/vendor/re2/{onepass.cc → re2/onepass.cc} +25 -27
  62. package/vendor/re2/{parse.cc → re2/parse.cc} +118 -121
  63. package/vendor/re2/{prefilter.cc → re2/prefilter.cc} +2 -3
  64. package/vendor/re2/{prefilter.h → re2/prefilter.h} +0 -1
  65. package/vendor/re2/{prefilter_tree.cc → re2/prefilter_tree.cc} +4 -5
  66. package/vendor/re2/{prefilter_tree.h → re2/prefilter_tree.h} +1 -2
  67. package/vendor/re2/{prog.cc → re2/prog.cc} +20 -21
  68. package/vendor/re2/{prog.h → re2/prog.h} +21 -22
  69. package/vendor/re2/{re2.cc → re2/re2.cc} +51 -62
  70. package/vendor/re2/{re2.h → re2/re2.h} +78 -40
  71. package/vendor/re2/{regexp.cc → re2/regexp.cc} +11 -12
  72. package/vendor/re2/{regexp.h → re2/regexp.h} +9 -10
  73. package/vendor/re2/{set.cc → re2/set.cc} +3 -5
  74. package/vendor/re2/{set.h → re2/set.h} +4 -3
  75. package/vendor/re2/{simplify.cc → re2/simplify.cc} +1 -2
  76. package/vendor/re2/re2/stringpiece.h +24 -0
  77. package/vendor/re2/{testing → re2/testing}/backtrack.cc +22 -25
  78. package/vendor/re2/{testing → re2/testing}/charclass_test.cc +23 -21
  79. package/vendor/re2/{testing → re2/testing}/compile_test.cc +5 -4
  80. package/vendor/re2/{testing → re2/testing}/dfa_test.cc +36 -30
  81. package/vendor/re2/{testing → re2/testing}/dump.cc +8 -8
  82. package/vendor/re2/{testing → re2/testing}/exhaustive1_test.cc +1 -1
  83. package/vendor/re2/{testing → re2/testing}/exhaustive2_test.cc +1 -1
  84. package/vendor/re2/{testing → re2/testing}/exhaustive3_test.cc +1 -1
  85. package/vendor/re2/{testing → re2/testing}/exhaustive_test.cc +1 -1
  86. package/vendor/re2/{testing → re2/testing}/exhaustive_tester.cc +36 -32
  87. package/vendor/re2/{testing → re2/testing}/exhaustive_tester.h +0 -1
  88. package/vendor/re2/{testing → re2/testing}/filtered_re2_test.cc +9 -8
  89. package/vendor/re2/{testing → re2/testing}/mimics_pcre_test.cc +3 -2
  90. package/vendor/re2/{testing → re2/testing}/null_walker.cc +1 -1
  91. package/vendor/re2/{testing → re2/testing}/parse_test.cc +13 -12
  92. package/vendor/re2/{testing → re2/testing}/possible_match_test.cc +15 -14
  93. package/vendor/re2/{testing → re2/testing}/random_test.cc +13 -12
  94. package/vendor/re2/{testing → re2/testing}/re2_arg_test.cc +25 -2
  95. package/vendor/re2/{testing → re2/testing}/re2_test.cc +49 -47
  96. package/vendor/re2/{testing → re2/testing}/regexp_benchmark.cc +144 -145
  97. package/vendor/re2/{testing → re2/testing}/regexp_generator.cc +18 -14
  98. package/vendor/re2/{testing → re2/testing}/regexp_generator.h +3 -4
  99. package/vendor/re2/{testing → re2/testing}/regexp_test.cc +1 -1
  100. package/vendor/re2/{testing → re2/testing}/required_prefix_test.cc +5 -4
  101. package/vendor/re2/{testing → re2/testing}/search_test.cc +3 -2
  102. package/vendor/re2/{testing → re2/testing}/set_test.cc +1 -1
  103. package/vendor/re2/{testing → re2/testing}/simplify_test.cc +3 -2
  104. package/vendor/re2/{testing → re2/testing}/string_generator.cc +3 -3
  105. package/vendor/re2/{testing → re2/testing}/string_generator.h +5 -6
  106. package/vendor/re2/{testing → re2/testing}/string_generator_test.cc +2 -2
  107. package/vendor/re2/{testing → re2/testing}/tester.cc +77 -78
  108. package/vendor/re2/{testing → re2/testing}/tester.h +13 -15
  109. package/vendor/re2/{tostring.cc → re2/tostring.cc} +7 -8
  110. package/vendor/re2/{unicode_casefold.h → re2/unicode_casefold.h} +0 -1
  111. package/vendor/re2/{unicode_groups.h → re2/unicode_groups.h} +0 -1
  112. package/vendor/re2/{walker-inl.h → re2/walker-inl.h} +2 -1
  113. package/vendor/re2/re2.pc.in +9 -0
  114. package/vendor/re2/re2Config.cmake.in +28 -0
  115. package/vendor/re2/runtests +33 -0
  116. package/vendor/re2/testinstall.cc +27 -0
  117. package/vendor/re2/ucs2.diff +567 -0
  118. package/vendor/{util → re2/util}/logging.h +2 -2
  119. package/vendor/{util → re2/util}/pcre.cc +47 -116
  120. package/vendor/{util → re2/util}/pcre.h +53 -63
  121. package/vendor/re2/util/strutil.cc +26 -0
  122. package/vendor/{util → re2/util}/strutil.h +0 -5
  123. package/vendor/re2/stringpiece.cc +0 -65
  124. package/vendor/re2/stringpiece.h +0 -213
  125. package/vendor/util/benchmark.cc +0 -131
  126. package/vendor/util/benchmark.h +0 -156
  127. package/vendor/util/flags.h +0 -26
  128. package/vendor/util/mix.h +0 -41
  129. package/vendor/util/mutex.h +0 -164
  130. package/vendor/util/strutil.cc +0 -149
  131. package/vendor/util/test.cc +0 -34
  132. package/vendor/util/test.h +0 -50
  133. package/vendor/util/util.h +0 -42
  134. /package/vendor/{LICENSE → re2/LICENSE} +0 -0
  135. /package/vendor/re2/{bitmap256.h → re2/bitmap256.h} +0 -0
  136. /package/vendor/re2/{fuzzing → re2/fuzzing}/compiler-rt/LICENSE +0 -0
  137. /package/vendor/re2/{fuzzing → re2/fuzzing}/compiler-rt/include/fuzzer/FuzzedDataProvider.h +0 -0
  138. /package/vendor/re2/{make_perl_groups.pl → re2/make_perl_groups.pl} +0 -0
  139. /package/vendor/re2/{make_unicode_casefold.py → re2/make_unicode_casefold.py} +0 -0
  140. /package/vendor/re2/{make_unicode_groups.py → re2/make_unicode_groups.py} +0 -0
  141. /package/vendor/re2/{perl_groups.cc → re2/perl_groups.cc} +0 -0
  142. /package/vendor/re2/{pod_array.h → re2/pod_array.h} +0 -0
  143. /package/vendor/re2/{sparse_array.h → re2/sparse_array.h} +0 -0
  144. /package/vendor/re2/{sparse_set.h → re2/sparse_set.h} +0 -0
  145. /package/vendor/re2/{unicode.py → re2/unicode.py} +0 -0
  146. /package/vendor/re2/{unicode_casefold.cc → re2/unicode_casefold.cc} +0 -0
  147. /package/vendor/re2/{unicode_groups.cc → re2/unicode_groups.cc} +0 -0
  148. /package/vendor/{util → re2/util}/fuzz.cc +0 -0
  149. /package/vendor/{util → re2/util}/malloc_counter.h +0 -0
  150. /package/vendor/{util → re2/util}/rune.cc +0 -0
  151. /package/vendor/{util → re2/util}/utf.h +0 -0
@@ -9,19 +9,18 @@
9
9
  #include <stdlib.h>
10
10
  #include <string>
11
11
  #include <thread>
12
- #include <unordered_map>
13
12
  #include <utility>
14
13
 
15
- #include "util/benchmark.h"
16
- #include "util/test.h"
17
- #include "util/flags.h"
14
+ #include "absl/container/flat_hash_map.h"
15
+ #include "absl/flags/flag.h"
16
+ #include "absl/strings/str_format.h"
17
+ #include "absl/synchronization/mutex.h"
18
+ #include "benchmark/benchmark.h"
18
19
  #include "util/logging.h"
19
20
  #include "util/malloc_counter.h"
20
- #include "util/strutil.h"
21
21
  #include "re2/prog.h"
22
22
  #include "re2/re2.h"
23
23
  #include "re2/regexp.h"
24
- #include "util/mutex.h"
25
24
  #include "util/pcre.h"
26
25
 
27
26
  namespace re2 {
@@ -41,7 +40,7 @@ void Test() {
41
40
  CHECK(prog->IsOnePass());
42
41
  CHECK(prog->CanBitState());
43
42
  const char* text = "650-253-0001";
44
- StringPiece sp[4];
43
+ absl::string_view sp[4];
45
44
  CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4));
46
45
  CHECK_EQ(sp[0], "650-253-0001");
47
46
  CHECK_EQ(sp[1], "650");
@@ -61,22 +60,22 @@ void MemoryUsage() {
61
60
  CHECK(re);
62
61
  // Can't pass mc.HeapGrowth() and mc.PeakHeapGrowth() to LOG(INFO) directly,
63
62
  // because LOG(INFO) might do a big allocation before they get evaluated.
64
- fprintf(stderr, "Regexp: %7lld bytes (peak=%lld)\n",
65
- mc.HeapGrowth(), mc.PeakHeapGrowth());
63
+ absl::FPrintF(stderr, "Regexp: %7d bytes (peak=%d)\n",
64
+ mc.HeapGrowth(), mc.PeakHeapGrowth());
66
65
  mc.Reset();
67
66
 
68
67
  Prog* prog = re->CompileToProg(0);
69
68
  CHECK(prog);
70
69
  CHECK(prog->IsOnePass());
71
70
  CHECK(prog->CanBitState());
72
- fprintf(stderr, "Prog: %7lld bytes (peak=%lld)\n",
73
- mc.HeapGrowth(), mc.PeakHeapGrowth());
71
+ absl::FPrintF(stderr, "Prog: %7d bytes (peak=%d)\n",
72
+ mc.HeapGrowth(), mc.PeakHeapGrowth());
74
73
  mc.Reset();
75
74
 
76
- StringPiece sp[4];
75
+ absl::string_view sp[4];
77
76
  CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4));
78
- fprintf(stderr, "Search: %7lld bytes (peak=%lld)\n",
79
- mc.HeapGrowth(), mc.PeakHeapGrowth());
77
+ absl::FPrintF(stderr, "Search: %7d bytes (peak=%d)\n",
78
+ mc.HeapGrowth(), mc.PeakHeapGrowth());
80
79
  delete prog;
81
80
  re->Decref();
82
81
  }
@@ -85,22 +84,22 @@ void MemoryUsage() {
85
84
  MallocCounter mc(MallocCounter::THIS_THREAD_ONLY);
86
85
 
87
86
  PCRE re(regexp, PCRE::UTF8);
88
- fprintf(stderr, "RE: %7lld bytes (peak=%lld)\n",
89
- mc.HeapGrowth(), mc.PeakHeapGrowth());
87
+ absl::FPrintF(stderr, "RE: %7d bytes (peak=%d)\n",
88
+ mc.HeapGrowth(), mc.PeakHeapGrowth());
90
89
  PCRE::FullMatch(text, re);
91
- fprintf(stderr, "RE: %7lld bytes (peak=%lld)\n",
92
- mc.HeapGrowth(), mc.PeakHeapGrowth());
90
+ absl::FPrintF(stderr, "RE: %7d bytes (peak=%d)\n",
91
+ mc.HeapGrowth(), mc.PeakHeapGrowth());
93
92
  }
94
93
 
95
94
  {
96
95
  MallocCounter mc(MallocCounter::THIS_THREAD_ONLY);
97
96
 
98
97
  PCRE* re = new PCRE(regexp, PCRE::UTF8);
99
- fprintf(stderr, "PCRE*: %7lld bytes (peak=%lld)\n",
100
- mc.HeapGrowth(), mc.PeakHeapGrowth());
98
+ absl::FPrintF(stderr, "PCRE*: %7d bytes (peak=%d)\n",
99
+ mc.HeapGrowth(), mc.PeakHeapGrowth());
101
100
  PCRE::FullMatch(text, *re);
102
- fprintf(stderr, "PCRE*: %7lld bytes (peak=%lld)\n",
103
- mc.HeapGrowth(), mc.PeakHeapGrowth());
101
+ absl::FPrintF(stderr, "PCRE*: %7d bytes (peak=%d)\n",
102
+ mc.HeapGrowth(), mc.PeakHeapGrowth());
104
103
  delete re;
105
104
  }
106
105
 
@@ -108,15 +107,15 @@ void MemoryUsage() {
108
107
  MallocCounter mc(MallocCounter::THIS_THREAD_ONLY);
109
108
 
110
109
  RE2 re(regexp);
111
- fprintf(stderr, "RE2: %7lld bytes (peak=%lld)\n",
112
- mc.HeapGrowth(), mc.PeakHeapGrowth());
110
+ absl::FPrintF(stderr, "RE2: %7d bytes (peak=%d)\n",
111
+ mc.HeapGrowth(), mc.PeakHeapGrowth());
113
112
  RE2::FullMatch(text, re);
114
- fprintf(stderr, "RE2: %7lld bytes (peak=%lld)\n",
115
- mc.HeapGrowth(), mc.PeakHeapGrowth());
113
+ absl::FPrintF(stderr, "RE2: %7d bytes (peak=%d)\n",
114
+ mc.HeapGrowth(), mc.PeakHeapGrowth());
116
115
  }
117
116
 
118
- fprintf(stderr, "sizeof: PCRE=%zd RE2=%zd Prog=%zd Inst=%zd\n",
119
- sizeof(PCRE), sizeof(RE2), sizeof(Prog), sizeof(Prog::Inst));
117
+ absl::FPrintF(stderr, "sizeof: PCRE=%d RE2=%d Prog=%d Inst=%d\n",
118
+ sizeof(PCRE), sizeof(RE2), sizeof(Prog), sizeof(Prog::Inst));
120
119
  }
121
120
 
122
121
  int NumCPUs() {
@@ -128,7 +127,7 @@ int NumCPUs() {
128
127
  // and not interesting.
129
128
 
130
129
  typedef void SearchImpl(benchmark::State& state, const char* regexp,
131
- const StringPiece& text, Prog::Anchor anchor,
130
+ absl::string_view text, Prog::Anchor anchor,
132
131
  bool expect_match);
133
132
 
134
133
  SearchImpl SearchDFA, SearchNFA, SearchOnePass, SearchBitState, SearchPCRE,
@@ -136,7 +135,7 @@ SearchImpl SearchDFA, SearchNFA, SearchOnePass, SearchBitState, SearchPCRE,
136
135
  SearchCachedBitState, SearchCachedPCRE, SearchCachedRE2;
137
136
 
138
137
  typedef void ParseImpl(benchmark::State& state, const char* regexp,
139
- const StringPiece& text);
138
+ absl::string_view text);
140
139
 
141
140
  ParseImpl Parse1NFA, Parse1OnePass, Parse1BitState, Parse1PCRE, Parse1RE2,
142
141
  Parse1Backtrack, Parse1CachedNFA, Parse1CachedOnePass, Parse1CachedBitState,
@@ -318,8 +317,8 @@ void FindAndConsume(benchmark::State& state) {
318
317
  s.append("Hello World");
319
318
  RE2 re("((Hello World))");
320
319
  for (auto _ : state) {
321
- StringPiece t = s;
322
- StringPiece u;
320
+ absl::string_view t = s;
321
+ absl::string_view u;
323
322
  CHECK(RE2::FindAndConsume(&t, re, &u));
324
323
  CHECK_EQ(u, "Hello World");
325
324
  }
@@ -442,7 +441,7 @@ BENCHMARK_RANGE(Search_AltMatch_CachedRE2, 8, 16<<20)->ThreadRange(1, NumCP
442
441
  // Benchmark: use regexp to find phone number.
443
442
 
444
443
  void SearchDigits(benchmark::State& state, SearchImpl* search) {
445
- StringPiece s("650-253-0001");
444
+ absl::string_view s("650-253-0001");
446
445
  search(state, "([0-9]+)-([0-9]+)-([0-9]+)", s, Prog::kAnchored, true);
447
446
  state.SetItemsProcessed(state.iterations());
448
447
  }
@@ -467,7 +466,7 @@ BENCHMARK(Search_Digits_BitState)->ThreadRange(1, NumCPUs());
467
466
 
468
467
  void Parse3Digits(benchmark::State& state,
469
468
  void (*parse3)(benchmark::State&, const char*,
470
- const StringPiece&)) {
469
+ absl::string_view)) {
471
470
  parse3(state, "([0-9]+)-([0-9]+)-([0-9]+)", "650-253-0001");
472
471
  state.SetItemsProcessed(state.iterations());
473
472
  }
@@ -506,7 +505,7 @@ BENCHMARK(Parse_CachedDigits_BitState)->ThreadRange(1, NumCPUs());
506
505
 
507
506
  void Parse3DigitDs(benchmark::State& state,
508
507
  void (*parse3)(benchmark::State&, const char*,
509
- const StringPiece&)) {
508
+ absl::string_view)) {
510
509
  parse3(state, "(\\d+)-(\\d+)-(\\d+)", "650-253-0001");
511
510
  state.SetItemsProcessed(state.iterations());
512
511
  }
@@ -547,7 +546,7 @@ BENCHMARK(Parse_CachedDigitDs_BitState)->ThreadRange(1, NumCPUs());
547
546
 
548
547
  void Parse1Split(benchmark::State& state,
549
548
  void (*parse1)(benchmark::State&, const char*,
550
- const StringPiece&)) {
549
+ absl::string_view)) {
551
550
  parse1(state, "[0-9]+-(.*)", "650-253-0001");
552
551
  state.SetItemsProcessed(state.iterations());
553
552
  }
@@ -584,7 +583,7 @@ BENCHMARK(Parse_CachedSplit_BitState)->ThreadRange(1, NumCPUs());
584
583
 
585
584
  void Parse1SplitHard(benchmark::State& state,
586
585
  void (*run)(benchmark::State&, const char*,
587
- const StringPiece&)) {
586
+ absl::string_view)) {
588
587
  run(state, "[0-9]+.(.*)", "650-253-0001");
589
588
  state.SetItemsProcessed(state.iterations());
590
589
  }
@@ -619,7 +618,7 @@ BENCHMARK(Parse_CachedSplitHard_Backtrack)->ThreadRange(1, NumCPUs());
619
618
 
620
619
  void Parse1SplitBig1(benchmark::State& state,
621
620
  void (*run)(benchmark::State&, const char*,
622
- const StringPiece&)) {
621
+ absl::string_view)) {
623
622
  std::string s;
624
623
  s.append(100000, 'x');
625
624
  s.append("650-253-0001");
@@ -639,7 +638,7 @@ BENCHMARK(Parse_CachedSplitBig1_RE2)->ThreadRange(1, NumCPUs());
639
638
 
640
639
  void Parse1SplitBig2(benchmark::State& state,
641
640
  void (*run)(benchmark::State&, const char*,
642
- const StringPiece&)) {
641
+ absl::string_view)) {
643
642
  std::string s;
644
643
  s.append("650-253-");
645
644
  s.append(100000, '0');
@@ -756,20 +755,20 @@ void RunBuild(benchmark::State& state, const std::string& regexp,
756
755
 
757
756
  } // namespace re2
758
757
 
759
- DEFINE_FLAG(std::string, compile_regexp, "(.*)-(\\d+)-of-(\\d+)",
760
- "regexp for compile benchmarks");
758
+ ABSL_FLAG(std::string, compile_regexp, "(.*)-(\\d+)-of-(\\d+)",
759
+ "regexp for compile benchmarks");
761
760
 
762
761
  namespace re2 {
763
762
 
764
- void BM_PCRE_Compile(benchmark::State& state) { RunBuild(state, GetFlag(FLAGS_compile_regexp), CompilePCRE); }
765
- void BM_Regexp_Parse(benchmark::State& state) { RunBuild(state, GetFlag(FLAGS_compile_regexp), ParseRegexp); }
766
- void BM_Regexp_Simplify(benchmark::State& state) { RunBuild(state, GetFlag(FLAGS_compile_regexp), SimplifyRegexp); }
767
- void BM_CompileToProg(benchmark::State& state) { RunBuild(state, GetFlag(FLAGS_compile_regexp), CompileToProg); }
768
- void BM_CompileByteMap(benchmark::State& state) { RunBuild(state, GetFlag(FLAGS_compile_regexp), CompileByteMap); }
769
- void BM_Regexp_Compile(benchmark::State& state) { RunBuild(state, GetFlag(FLAGS_compile_regexp), CompileRegexp); }
770
- void BM_Regexp_SimplifyCompile(benchmark::State& state) { RunBuild(state, GetFlag(FLAGS_compile_regexp), SimplifyCompileRegexp); }
771
- void BM_Regexp_NullWalk(benchmark::State& state) { RunBuild(state, GetFlag(FLAGS_compile_regexp), NullWalkRegexp); }
772
- void BM_RE2_Compile(benchmark::State& state) { RunBuild(state, GetFlag(FLAGS_compile_regexp), CompileRE2); }
763
+ void BM_PCRE_Compile(benchmark::State& state) { RunBuild(state, absl::GetFlag(FLAGS_compile_regexp), CompilePCRE); }
764
+ void BM_Regexp_Parse(benchmark::State& state) { RunBuild(state, absl::GetFlag(FLAGS_compile_regexp), ParseRegexp); }
765
+ void BM_Regexp_Simplify(benchmark::State& state) { RunBuild(state, absl::GetFlag(FLAGS_compile_regexp), SimplifyRegexp); }
766
+ void BM_CompileToProg(benchmark::State& state) { RunBuild(state, absl::GetFlag(FLAGS_compile_regexp), CompileToProg); }
767
+ void BM_CompileByteMap(benchmark::State& state) { RunBuild(state, absl::GetFlag(FLAGS_compile_regexp), CompileByteMap); }
768
+ void BM_Regexp_Compile(benchmark::State& state) { RunBuild(state, absl::GetFlag(FLAGS_compile_regexp), CompileRegexp); }
769
+ void BM_Regexp_SimplifyCompile(benchmark::State& state) { RunBuild(state, absl::GetFlag(FLAGS_compile_regexp), SimplifyCompileRegexp); }
770
+ void BM_Regexp_NullWalk(benchmark::State& state) { RunBuild(state, absl::GetFlag(FLAGS_compile_regexp), NullWalkRegexp); }
771
+ void BM_RE2_Compile(benchmark::State& state) { RunBuild(state, absl::GetFlag(FLAGS_compile_regexp), CompileRE2); }
773
772
 
774
773
  #ifdef USEPCRE
775
774
  BENCHMARK(BM_PCRE_Compile)->ThreadRange(1, NumCPUs());
@@ -859,7 +858,7 @@ DO24(MY_BENCHMARK_WITH_ARG, CacheFillDFA)
859
858
  // Anchored says whether to run an anchored search.
860
859
 
861
860
  void SearchDFA(benchmark::State& state, const char* regexp,
862
- const StringPiece& text, Prog::Anchor anchor,
861
+ absl::string_view text, Prog::Anchor anchor,
863
862
  bool expect_match) {
864
863
  for (auto _ : state) {
865
864
  Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL);
@@ -867,8 +866,8 @@ void SearchDFA(benchmark::State& state, const char* regexp,
867
866
  Prog* prog = re->CompileToProg(0);
868
867
  CHECK(prog);
869
868
  bool failed = false;
870
- CHECK_EQ(prog->SearchDFA(text, StringPiece(), anchor, Prog::kFirstMatch,
871
- NULL, &failed, NULL),
869
+ CHECK_EQ(prog->SearchDFA(text, absl::string_view(), anchor,
870
+ Prog::kFirstMatch, NULL, &failed, NULL),
872
871
  expect_match);
873
872
  CHECK(!failed);
874
873
  delete prog;
@@ -877,15 +876,15 @@ void SearchDFA(benchmark::State& state, const char* regexp,
877
876
  }
878
877
 
879
878
  void SearchNFA(benchmark::State& state, const char* regexp,
880
- const StringPiece& text, Prog::Anchor anchor,
879
+ absl::string_view text, Prog::Anchor anchor,
881
880
  bool expect_match) {
882
881
  for (auto _ : state) {
883
882
  Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL);
884
883
  CHECK(re);
885
884
  Prog* prog = re->CompileToProg(0);
886
885
  CHECK(prog);
887
- CHECK_EQ(prog->SearchNFA(text, StringPiece(), anchor, Prog::kFirstMatch,
888
- NULL, 0),
886
+ CHECK_EQ(prog->SearchNFA(text, absl::string_view(), anchor,
887
+ Prog::kFirstMatch, NULL, 0),
889
888
  expect_match);
890
889
  delete prog;
891
890
  re->Decref();
@@ -893,7 +892,7 @@ void SearchNFA(benchmark::State& state, const char* regexp,
893
892
  }
894
893
 
895
894
  void SearchOnePass(benchmark::State& state, const char* regexp,
896
- const StringPiece& text, Prog::Anchor anchor,
895
+ absl::string_view text, Prog::Anchor anchor,
897
896
  bool expect_match) {
898
897
  for (auto _ : state) {
899
898
  Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL);
@@ -909,7 +908,7 @@ void SearchOnePass(benchmark::State& state, const char* regexp,
909
908
  }
910
909
 
911
910
  void SearchBitState(benchmark::State& state, const char* regexp,
912
- const StringPiece& text, Prog::Anchor anchor,
911
+ absl::string_view text, Prog::Anchor anchor,
913
912
  bool expect_match) {
914
913
  for (auto _ : state) {
915
914
  Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL);
@@ -925,7 +924,7 @@ void SearchBitState(benchmark::State& state, const char* regexp,
925
924
  }
926
925
 
927
926
  void SearchPCRE(benchmark::State& state, const char* regexp,
928
- const StringPiece& text, Prog::Anchor anchor,
927
+ absl::string_view text, Prog::Anchor anchor,
929
928
  bool expect_match) {
930
929
  for (auto _ : state) {
931
930
  PCRE re(regexp, PCRE::UTF8);
@@ -938,7 +937,7 @@ void SearchPCRE(benchmark::State& state, const char* regexp,
938
937
  }
939
938
 
940
939
  void SearchRE2(benchmark::State& state, const char* regexp,
941
- const StringPiece& text, Prog::Anchor anchor,
940
+ absl::string_view text, Prog::Anchor anchor,
942
941
  bool expect_match) {
943
942
  for (auto _ : state) {
944
943
  RE2 re(regexp);
@@ -955,9 +954,9 @@ void SearchRE2(benchmark::State& state, const char* regexp,
955
954
  // search time without the per-regexp overhead.
956
955
 
957
956
  Prog* GetCachedProg(const char* regexp) {
958
- static auto& mutex = *new Mutex;
959
- MutexLock lock(&mutex);
960
- static auto& cache = *new std::unordered_map<std::string, Prog*>;
957
+ static auto& mutex = *new absl::Mutex;
958
+ absl::MutexLock lock(&mutex);
959
+ static auto& cache = *new absl::flat_hash_map<std::string, Prog*>;
961
960
  Prog* prog = cache[regexp];
962
961
  if (prog == NULL) {
963
962
  Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL);
@@ -973,9 +972,9 @@ Prog* GetCachedProg(const char* regexp) {
973
972
  }
974
973
 
975
974
  PCRE* GetCachedPCRE(const char* regexp) {
976
- static auto& mutex = *new Mutex;
977
- MutexLock lock(&mutex);
978
- static auto& cache = *new std::unordered_map<std::string, PCRE*>;
975
+ static auto& mutex = *new absl::Mutex;
976
+ absl::MutexLock lock(&mutex);
977
+ static auto& cache = *new absl::flat_hash_map<std::string, PCRE*>;
979
978
  PCRE* re = cache[regexp];
980
979
  if (re == NULL) {
981
980
  re = new PCRE(regexp, PCRE::UTF8);
@@ -986,9 +985,9 @@ PCRE* GetCachedPCRE(const char* regexp) {
986
985
  }
987
986
 
988
987
  RE2* GetCachedRE2(const char* regexp) {
989
- static auto& mutex = *new Mutex;
990
- MutexLock lock(&mutex);
991
- static auto& cache = *new std::unordered_map<std::string, RE2*>;
988
+ static auto& mutex = *new absl::Mutex;
989
+ absl::MutexLock lock(&mutex);
990
+ static auto& cache = *new absl::flat_hash_map<std::string, RE2*>;
992
991
  RE2* re = cache[regexp];
993
992
  if (re == NULL) {
994
993
  re = new RE2(regexp);
@@ -999,31 +998,31 @@ RE2* GetCachedRE2(const char* regexp) {
999
998
  }
1000
999
 
1001
1000
  void SearchCachedDFA(benchmark::State& state, const char* regexp,
1002
- const StringPiece& text, Prog::Anchor anchor,
1001
+ absl::string_view text, Prog::Anchor anchor,
1003
1002
  bool expect_match) {
1004
1003
  Prog* prog = GetCachedProg(regexp);
1005
1004
  for (auto _ : state) {
1006
1005
  bool failed = false;
1007
- CHECK_EQ(prog->SearchDFA(text, StringPiece(), anchor, Prog::kFirstMatch,
1008
- NULL, &failed, NULL),
1006
+ CHECK_EQ(prog->SearchDFA(text, absl::string_view(), anchor,
1007
+ Prog::kFirstMatch, NULL, &failed, NULL),
1009
1008
  expect_match);
1010
1009
  CHECK(!failed);
1011
1010
  }
1012
1011
  }
1013
1012
 
1014
1013
  void SearchCachedNFA(benchmark::State& state, const char* regexp,
1015
- const StringPiece& text, Prog::Anchor anchor,
1014
+ absl::string_view text, Prog::Anchor anchor,
1016
1015
  bool expect_match) {
1017
1016
  Prog* prog = GetCachedProg(regexp);
1018
1017
  for (auto _ : state) {
1019
- CHECK_EQ(prog->SearchNFA(text, StringPiece(), anchor, Prog::kFirstMatch,
1020
- NULL, 0),
1018
+ CHECK_EQ(prog->SearchNFA(text, absl::string_view(), anchor,
1019
+ Prog::kFirstMatch, NULL, 0),
1021
1020
  expect_match);
1022
1021
  }
1023
1022
  }
1024
1023
 
1025
1024
  void SearchCachedOnePass(benchmark::State& state, const char* regexp,
1026
- const StringPiece& text, Prog::Anchor anchor,
1025
+ absl::string_view text, Prog::Anchor anchor,
1027
1026
  bool expect_match) {
1028
1027
  Prog* prog = GetCachedProg(regexp);
1029
1028
  CHECK(prog->IsOnePass());
@@ -1034,7 +1033,7 @@ void SearchCachedOnePass(benchmark::State& state, const char* regexp,
1034
1033
  }
1035
1034
 
1036
1035
  void SearchCachedBitState(benchmark::State& state, const char* regexp,
1037
- const StringPiece& text, Prog::Anchor anchor,
1036
+ absl::string_view text, Prog::Anchor anchor,
1038
1037
  bool expect_match) {
1039
1038
  Prog* prog = GetCachedProg(regexp);
1040
1039
  CHECK(prog->CanBitState());
@@ -1045,7 +1044,7 @@ void SearchCachedBitState(benchmark::State& state, const char* regexp,
1045
1044
  }
1046
1045
 
1047
1046
  void SearchCachedPCRE(benchmark::State& state, const char* regexp,
1048
- const StringPiece& text, Prog::Anchor anchor,
1047
+ absl::string_view text, Prog::Anchor anchor,
1049
1048
  bool expect_match) {
1050
1049
  PCRE& re = *GetCachedPCRE(regexp);
1051
1050
  for (auto _ : state) {
@@ -1057,7 +1056,7 @@ void SearchCachedPCRE(benchmark::State& state, const char* regexp,
1057
1056
  }
1058
1057
 
1059
1058
  void SearchCachedRE2(benchmark::State& state, const char* regexp,
1060
- const StringPiece& text, Prog::Anchor anchor,
1059
+ absl::string_view text, Prog::Anchor anchor,
1061
1060
  bool expect_match) {
1062
1061
  RE2& re = *GetCachedRE2(regexp);
1063
1062
  for (auto _ : state) {
@@ -1072,14 +1071,14 @@ void SearchCachedRE2(benchmark::State& state, const char* regexp,
1072
1071
  // extracting three submatches. Expects match always.
1073
1072
 
1074
1073
  void Parse3NFA(benchmark::State& state, const char* regexp,
1075
- const StringPiece& text) {
1074
+ absl::string_view text) {
1076
1075
  for (auto _ : state) {
1077
1076
  Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL);
1078
1077
  CHECK(re);
1079
1078
  Prog* prog = re->CompileToProg(0);
1080
1079
  CHECK(prog);
1081
- StringPiece sp[4]; // 4 because sp[0] is whole match.
1082
- CHECK(prog->SearchNFA(text, StringPiece(), Prog::kAnchored,
1080
+ absl::string_view sp[4]; // 4 because sp[0] is whole match.
1081
+ CHECK(prog->SearchNFA(text, absl::string_view(), Prog::kAnchored,
1083
1082
  Prog::kFullMatch, sp, 4));
1084
1083
  delete prog;
1085
1084
  re->Decref();
@@ -1087,14 +1086,14 @@ void Parse3NFA(benchmark::State& state, const char* regexp,
1087
1086
  }
1088
1087
 
1089
1088
  void Parse3OnePass(benchmark::State& state, const char* regexp,
1090
- const StringPiece& text) {
1089
+ absl::string_view text) {
1091
1090
  for (auto _ : state) {
1092
1091
  Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL);
1093
1092
  CHECK(re);
1094
1093
  Prog* prog = re->CompileToProg(0);
1095
1094
  CHECK(prog);
1096
1095
  CHECK(prog->IsOnePass());
1097
- StringPiece sp[4]; // 4 because sp[0] is whole match.
1096
+ absl::string_view sp[4]; // 4 because sp[0] is whole match.
1098
1097
  CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4));
1099
1098
  delete prog;
1100
1099
  re->Decref();
@@ -1102,14 +1101,14 @@ void Parse3OnePass(benchmark::State& state, const char* regexp,
1102
1101
  }
1103
1102
 
1104
1103
  void Parse3BitState(benchmark::State& state, const char* regexp,
1105
- const StringPiece& text) {
1104
+ absl::string_view text) {
1106
1105
  for (auto _ : state) {
1107
1106
  Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL);
1108
1107
  CHECK(re);
1109
1108
  Prog* prog = re->CompileToProg(0);
1110
1109
  CHECK(prog);
1111
1110
  CHECK(prog->CanBitState());
1112
- StringPiece sp[4]; // 4 because sp[0] is whole match.
1111
+ absl::string_view sp[4]; // 4 because sp[0] is whole match.
1113
1112
  CHECK(prog->SearchBitState(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4));
1114
1113
  delete prog;
1115
1114
  re->Decref();
@@ -1117,13 +1116,13 @@ void Parse3BitState(benchmark::State& state, const char* regexp,
1117
1116
  }
1118
1117
 
1119
1118
  void Parse3Backtrack(benchmark::State& state, const char* regexp,
1120
- const StringPiece& text) {
1119
+ absl::string_view text) {
1121
1120
  for (auto _ : state) {
1122
1121
  Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL);
1123
1122
  CHECK(re);
1124
1123
  Prog* prog = re->CompileToProg(0);
1125
1124
  CHECK(prog);
1126
- StringPiece sp[4]; // 4 because sp[0] is whole match.
1125
+ absl::string_view sp[4]; // 4 because sp[0] is whole match.
1127
1126
  CHECK(prog->UnsafeSearchBacktrack(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4));
1128
1127
  delete prog;
1129
1128
  re->Decref();
@@ -1131,77 +1130,77 @@ void Parse3Backtrack(benchmark::State& state, const char* regexp,
1131
1130
  }
1132
1131
 
1133
1132
  void Parse3PCRE(benchmark::State& state, const char* regexp,
1134
- const StringPiece& text) {
1133
+ absl::string_view text) {
1135
1134
  for (auto _ : state) {
1136
1135
  PCRE re(regexp, PCRE::UTF8);
1137
1136
  CHECK_EQ(re.error(), "");
1138
- StringPiece sp1, sp2, sp3;
1137
+ absl::string_view sp1, sp2, sp3;
1139
1138
  CHECK(PCRE::FullMatch(text, re, &sp1, &sp2, &sp3));
1140
1139
  }
1141
1140
  }
1142
1141
 
1143
1142
  void Parse3RE2(benchmark::State& state, const char* regexp,
1144
- const StringPiece& text) {
1143
+ absl::string_view text) {
1145
1144
  for (auto _ : state) {
1146
1145
  RE2 re(regexp);
1147
1146
  CHECK_EQ(re.error(), "");
1148
- StringPiece sp1, sp2, sp3;
1147
+ absl::string_view sp1, sp2, sp3;
1149
1148
  CHECK(RE2::FullMatch(text, re, &sp1, &sp2, &sp3));
1150
1149
  }
1151
1150
  }
1152
1151
 
1153
1152
  void Parse3CachedNFA(benchmark::State& state, const char* regexp,
1154
- const StringPiece& text) {
1153
+ absl::string_view text) {
1155
1154
  Prog* prog = GetCachedProg(regexp);
1156
- StringPiece sp[4]; // 4 because sp[0] is whole match.
1155
+ absl::string_view sp[4]; // 4 because sp[0] is whole match.
1157
1156
  for (auto _ : state) {
1158
- CHECK(prog->SearchNFA(text, StringPiece(), Prog::kAnchored,
1157
+ CHECK(prog->SearchNFA(text, absl::string_view(), Prog::kAnchored,
1159
1158
  Prog::kFullMatch, sp, 4));
1160
1159
  }
1161
1160
  }
1162
1161
 
1163
1162
  void Parse3CachedOnePass(benchmark::State& state, const char* regexp,
1164
- const StringPiece& text) {
1163
+ absl::string_view text) {
1165
1164
  Prog* prog = GetCachedProg(regexp);
1166
1165
  CHECK(prog->IsOnePass());
1167
- StringPiece sp[4]; // 4 because sp[0] is whole match.
1166
+ absl::string_view sp[4]; // 4 because sp[0] is whole match.
1168
1167
  for (auto _ : state) {
1169
1168
  CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4));
1170
1169
  }
1171
1170
  }
1172
1171
 
1173
1172
  void Parse3CachedBitState(benchmark::State& state, const char* regexp,
1174
- const StringPiece& text) {
1173
+ absl::string_view text) {
1175
1174
  Prog* prog = GetCachedProg(regexp);
1176
1175
  CHECK(prog->CanBitState());
1177
- StringPiece sp[4]; // 4 because sp[0] is whole match.
1176
+ absl::string_view sp[4]; // 4 because sp[0] is whole match.
1178
1177
  for (auto _ : state) {
1179
1178
  CHECK(prog->SearchBitState(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4));
1180
1179
  }
1181
1180
  }
1182
1181
 
1183
1182
  void Parse3CachedBacktrack(benchmark::State& state, const char* regexp,
1184
- const StringPiece& text) {
1183
+ absl::string_view text) {
1185
1184
  Prog* prog = GetCachedProg(regexp);
1186
- StringPiece sp[4]; // 4 because sp[0] is whole match.
1185
+ absl::string_view sp[4]; // 4 because sp[0] is whole match.
1187
1186
  for (auto _ : state) {
1188
1187
  CHECK(prog->UnsafeSearchBacktrack(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4));
1189
1188
  }
1190
1189
  }
1191
1190
 
1192
1191
  void Parse3CachedPCRE(benchmark::State& state, const char* regexp,
1193
- const StringPiece& text) {
1192
+ absl::string_view text) {
1194
1193
  PCRE& re = *GetCachedPCRE(regexp);
1195
- StringPiece sp1, sp2, sp3;
1194
+ absl::string_view sp1, sp2, sp3;
1196
1195
  for (auto _ : state) {
1197
1196
  CHECK(PCRE::FullMatch(text, re, &sp1, &sp2, &sp3));
1198
1197
  }
1199
1198
  }
1200
1199
 
1201
1200
  void Parse3CachedRE2(benchmark::State& state, const char* regexp,
1202
- const StringPiece& text) {
1201
+ absl::string_view text) {
1203
1202
  RE2& re = *GetCachedRE2(regexp);
1204
- StringPiece sp1, sp2, sp3;
1203
+ absl::string_view sp1, sp2, sp3;
1205
1204
  for (auto _ : state) {
1206
1205
  CHECK(RE2::FullMatch(text, re, &sp1, &sp2, &sp3));
1207
1206
  }
@@ -1211,14 +1210,14 @@ void Parse3CachedRE2(benchmark::State& state, const char* regexp,
1211
1210
  // extracting three submatches. Expects match always.
1212
1211
 
1213
1212
  void Parse1NFA(benchmark::State& state, const char* regexp,
1214
- const StringPiece& text) {
1213
+ absl::string_view text) {
1215
1214
  for (auto _ : state) {
1216
1215
  Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL);
1217
1216
  CHECK(re);
1218
1217
  Prog* prog = re->CompileToProg(0);
1219
1218
  CHECK(prog);
1220
- StringPiece sp[2]; // 2 because sp[0] is whole match.
1221
- CHECK(prog->SearchNFA(text, StringPiece(), Prog::kAnchored,
1219
+ absl::string_view sp[2]; // 2 because sp[0] is whole match.
1220
+ CHECK(prog->SearchNFA(text, absl::string_view(), Prog::kAnchored,
1222
1221
  Prog::kFullMatch, sp, 2));
1223
1222
  delete prog;
1224
1223
  re->Decref();
@@ -1226,14 +1225,14 @@ void Parse1NFA(benchmark::State& state, const char* regexp,
1226
1225
  }
1227
1226
 
1228
1227
  void Parse1OnePass(benchmark::State& state, const char* regexp,
1229
- const StringPiece& text) {
1228
+ absl::string_view text) {
1230
1229
  for (auto _ : state) {
1231
1230
  Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL);
1232
1231
  CHECK(re);
1233
1232
  Prog* prog = re->CompileToProg(0);
1234
1233
  CHECK(prog);
1235
1234
  CHECK(prog->IsOnePass());
1236
- StringPiece sp[2]; // 2 because sp[0] is whole match.
1235
+ absl::string_view sp[2]; // 2 because sp[0] is whole match.
1237
1236
  CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 2));
1238
1237
  delete prog;
1239
1238
  re->Decref();
@@ -1241,14 +1240,14 @@ void Parse1OnePass(benchmark::State& state, const char* regexp,
1241
1240
  }
1242
1241
 
1243
1242
  void Parse1BitState(benchmark::State& state, const char* regexp,
1244
- const StringPiece& text) {
1243
+ absl::string_view text) {
1245
1244
  for (auto _ : state) {
1246
1245
  Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL);
1247
1246
  CHECK(re);
1248
1247
  Prog* prog = re->CompileToProg(0);
1249
1248
  CHECK(prog);
1250
1249
  CHECK(prog->CanBitState());
1251
- StringPiece sp[2]; // 2 because sp[0] is whole match.
1250
+ absl::string_view sp[2]; // 2 because sp[0] is whole match.
1252
1251
  CHECK(prog->SearchBitState(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 2));
1253
1252
  delete prog;
1254
1253
  re->Decref();
@@ -1256,114 +1255,114 @@ void Parse1BitState(benchmark::State& state, const char* regexp,
1256
1255
  }
1257
1256
 
1258
1257
  void Parse1PCRE(benchmark::State& state, const char* regexp,
1259
- const StringPiece& text) {
1258
+ absl::string_view text) {
1260
1259
  for (auto _ : state) {
1261
1260
  PCRE re(regexp, PCRE::UTF8);
1262
1261
  CHECK_EQ(re.error(), "");
1263
- StringPiece sp1;
1262
+ absl::string_view sp1;
1264
1263
  CHECK(PCRE::FullMatch(text, re, &sp1));
1265
1264
  }
1266
1265
  }
1267
1266
 
1268
1267
  void Parse1RE2(benchmark::State& state, const char* regexp,
1269
- const StringPiece& text) {
1268
+ absl::string_view text) {
1270
1269
  for (auto _ : state) {
1271
1270
  RE2 re(regexp);
1272
1271
  CHECK_EQ(re.error(), "");
1273
- StringPiece sp1;
1272
+ absl::string_view sp1;
1274
1273
  CHECK(RE2::FullMatch(text, re, &sp1));
1275
1274
  }
1276
1275
  }
1277
1276
 
1278
1277
  void Parse1CachedNFA(benchmark::State& state, const char* regexp,
1279
- const StringPiece& text) {
1278
+ absl::string_view text) {
1280
1279
  Prog* prog = GetCachedProg(regexp);
1281
- StringPiece sp[2]; // 2 because sp[0] is whole match.
1280
+ absl::string_view sp[2]; // 2 because sp[0] is whole match.
1282
1281
  for (auto _ : state) {
1283
- CHECK(prog->SearchNFA(text, StringPiece(), Prog::kAnchored,
1282
+ CHECK(prog->SearchNFA(text, absl::string_view(), Prog::kAnchored,
1284
1283
  Prog::kFullMatch, sp, 2));
1285
1284
  }
1286
1285
  }
1287
1286
 
1288
1287
  void Parse1CachedOnePass(benchmark::State& state, const char* regexp,
1289
- const StringPiece& text) {
1288
+ absl::string_view text) {
1290
1289
  Prog* prog = GetCachedProg(regexp);
1291
1290
  CHECK(prog->IsOnePass());
1292
- StringPiece sp[2]; // 2 because sp[0] is whole match.
1291
+ absl::string_view sp[2]; // 2 because sp[0] is whole match.
1293
1292
  for (auto _ : state) {
1294
1293
  CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 2));
1295
1294
  }
1296
1295
  }
1297
1296
 
1298
1297
  void Parse1CachedBitState(benchmark::State& state, const char* regexp,
1299
- const StringPiece& text) {
1298
+ absl::string_view text) {
1300
1299
  Prog* prog = GetCachedProg(regexp);
1301
1300
  CHECK(prog->CanBitState());
1302
- StringPiece sp[2]; // 2 because sp[0] is whole match.
1301
+ absl::string_view sp[2]; // 2 because sp[0] is whole match.
1303
1302
  for (auto _ : state) {
1304
1303
  CHECK(prog->SearchBitState(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 2));
1305
1304
  }
1306
1305
  }
1307
1306
 
1308
1307
  void Parse1CachedBacktrack(benchmark::State& state, const char* regexp,
1309
- const StringPiece& text) {
1308
+ absl::string_view text) {
1310
1309
  Prog* prog = GetCachedProg(regexp);
1311
- StringPiece sp[2]; // 2 because sp[0] is whole match.
1310
+ absl::string_view sp[2]; // 2 because sp[0] is whole match.
1312
1311
  for (auto _ : state) {
1313
1312
  CHECK(prog->UnsafeSearchBacktrack(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 2));
1314
1313
  }
1315
1314
  }
1316
1315
 
1317
1316
  void Parse1CachedPCRE(benchmark::State& state, const char* regexp,
1318
- const StringPiece& text) {
1317
+ absl::string_view text) {
1319
1318
  PCRE& re = *GetCachedPCRE(regexp);
1320
- StringPiece sp1;
1319
+ absl::string_view sp1;
1321
1320
  for (auto _ : state) {
1322
1321
  CHECK(PCRE::FullMatch(text, re, &sp1));
1323
1322
  }
1324
1323
  }
1325
1324
 
1326
1325
  void Parse1CachedRE2(benchmark::State& state, const char* regexp,
1327
- const StringPiece& text) {
1326
+ absl::string_view text) {
1328
1327
  RE2& re = *GetCachedRE2(regexp);
1329
- StringPiece sp1;
1328
+ absl::string_view sp1;
1330
1329
  for (auto _ : state) {
1331
1330
  CHECK(RE2::FullMatch(text, re, &sp1));
1332
1331
  }
1333
1332
  }
1334
1333
 
1335
1334
  void SearchParse2CachedPCRE(benchmark::State& state, const char* regexp,
1336
- const StringPiece& text) {
1335
+ absl::string_view text) {
1337
1336
  PCRE& re = *GetCachedPCRE(regexp);
1338
1337
  for (auto _ : state) {
1339
- StringPiece sp1, sp2;
1338
+ absl::string_view sp1, sp2;
1340
1339
  CHECK(PCRE::PartialMatch(text, re, &sp1, &sp2));
1341
1340
  }
1342
1341
  }
1343
1342
 
1344
1343
  void SearchParse2CachedRE2(benchmark::State& state, const char* regexp,
1345
- const StringPiece& text) {
1344
+ absl::string_view text) {
1346
1345
  RE2& re = *GetCachedRE2(regexp);
1347
1346
  for (auto _ : state) {
1348
- StringPiece sp1, sp2;
1347
+ absl::string_view sp1, sp2;
1349
1348
  CHECK(RE2::PartialMatch(text, re, &sp1, &sp2));
1350
1349
  }
1351
1350
  }
1352
1351
 
1353
1352
  void SearchParse1CachedPCRE(benchmark::State& state, const char* regexp,
1354
- const StringPiece& text) {
1353
+ absl::string_view text) {
1355
1354
  PCRE& re = *GetCachedPCRE(regexp);
1356
1355
  for (auto _ : state) {
1357
- StringPiece sp1;
1356
+ absl::string_view sp1;
1358
1357
  CHECK(PCRE::PartialMatch(text, re, &sp1));
1359
1358
  }
1360
1359
  }
1361
1360
 
1362
1361
  void SearchParse1CachedRE2(benchmark::State& state, const char* regexp,
1363
- const StringPiece& text) {
1362
+ absl::string_view text) {
1364
1363
  RE2& re = *GetCachedRE2(regexp);
1365
1364
  for (auto _ : state) {
1366
- StringPiece sp1;
1365
+ absl::string_view sp1;
1367
1366
  CHECK(RE2::PartialMatch(text, re, &sp1));
1368
1367
  }
1369
1368
  }
@@ -1409,7 +1408,7 @@ static std::string http_text =
1409
1408
  "alksdjfhasdlkfhasdlkjfhasdljkfhadsjklf HTTP/1.1";
1410
1409
 
1411
1410
  void HTTPPartialMatchPCRE(benchmark::State& state) {
1412
- StringPiece a;
1411
+ absl::string_view a;
1413
1412
  PCRE re("(?-s)^(?:GET|POST) +([^ ]+) HTTP");
1414
1413
  for (auto _ : state) {
1415
1414
  PCRE::PartialMatch(http_text, re, &a);
@@ -1417,7 +1416,7 @@ void HTTPPartialMatchPCRE(benchmark::State& state) {
1417
1416
  }
1418
1417
 
1419
1418
  void HTTPPartialMatchRE2(benchmark::State& state) {
1420
- StringPiece a;
1419
+ absl::string_view a;
1421
1420
  RE2 re("(?-s)^(?:GET|POST) +([^ ]+) HTTP");
1422
1421
  for (auto _ : state) {
1423
1422
  RE2::PartialMatch(http_text, re, &a);
@@ -1433,7 +1432,7 @@ static std::string smallhttp_text =
1433
1432
  "GET /abc HTTP/1.1";
1434
1433
 
1435
1434
  void SmallHTTPPartialMatchPCRE(benchmark::State& state) {
1436
- StringPiece a;
1435
+ absl::string_view a;
1437
1436
  PCRE re("(?-s)^(?:GET|POST) +([^ ]+) HTTP");
1438
1437
  for (auto _ : state) {
1439
1438
  PCRE::PartialMatch(smallhttp_text, re, &a);
@@ -1441,7 +1440,7 @@ void SmallHTTPPartialMatchPCRE(benchmark::State& state) {
1441
1440
  }
1442
1441
 
1443
1442
  void SmallHTTPPartialMatchRE2(benchmark::State& state) {
1444
- StringPiece a;
1443
+ absl::string_view a;
1445
1444
  RE2 re("(?-s)^(?:GET|POST) +([^ ]+) HTTP");
1446
1445
  for (auto _ : state) {
1447
1446
  RE2::PartialMatch(smallhttp_text, re, &a);
@@ -1454,7 +1453,7 @@ BENCHMARK(SmallHTTPPartialMatchPCRE)->ThreadRange(1, NumCPUs());
1454
1453
  BENCHMARK(SmallHTTPPartialMatchRE2)->ThreadRange(1, NumCPUs());
1455
1454
 
1456
1455
  void DotMatchPCRE(benchmark::State& state) {
1457
- StringPiece a;
1456
+ absl::string_view a;
1458
1457
  PCRE re("(?-s)^(.+)");
1459
1458
  for (auto _ : state) {
1460
1459
  PCRE::PartialMatch(http_text, re, &a);
@@ -1462,7 +1461,7 @@ void DotMatchPCRE(benchmark::State& state) {
1462
1461
  }
1463
1462
 
1464
1463
  void DotMatchRE2(benchmark::State& state) {
1465
- StringPiece a;
1464
+ absl::string_view a;
1466
1465
  RE2 re("(?-s)^(.+)");
1467
1466
  for (auto _ : state) {
1468
1467
  RE2::PartialMatch(http_text, re, &a);
@@ -1475,7 +1474,7 @@ BENCHMARK(DotMatchPCRE)->ThreadRange(1, NumCPUs());
1475
1474
  BENCHMARK(DotMatchRE2)->ThreadRange(1, NumCPUs());
1476
1475
 
1477
1476
  void ASCIIMatchPCRE(benchmark::State& state) {
1478
- StringPiece a;
1477
+ absl::string_view a;
1479
1478
  PCRE re("(?-s)^([ -~]+)");
1480
1479
  for (auto _ : state) {
1481
1480
  PCRE::PartialMatch(http_text, re, &a);
@@ -1483,7 +1482,7 @@ void ASCIIMatchPCRE(benchmark::State& state) {
1483
1482
  }
1484
1483
 
1485
1484
  void ASCIIMatchRE2(benchmark::State& state) {
1486
- StringPiece a;
1485
+ absl::string_view a;
1487
1486
  RE2 re("(?-s)^([ -~]+)");
1488
1487
  for (auto _ : state) {
1489
1488
  RE2::PartialMatch(http_text, re, &a);