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.
- package/.github/actions/linux-alpine-node-16/Dockerfile +1 -1
- package/.github/actions/linux-alpine-node-18/Dockerfile +1 -1
- package/.github/actions/linux-alpine-node-20/Dockerfile +1 -1
- package/.gitmodules +5 -2
- package/README.md +1 -0
- package/binding.gyp +82 -25
- package/lib/replace.cc +4 -4
- package/package.json +1 -1
- package/tsconfig.json +2 -1
- package/vendor/re2/.bazelrc +16 -0
- package/vendor/re2/.github/bazel.sh +24 -0
- package/vendor/re2/.github/cmake.sh +12 -0
- package/vendor/re2/.github/workflows/ci-bazel.yml +17 -0
- package/vendor/re2/.github/workflows/ci-cmake.yml +108 -0
- package/vendor/re2/.github/workflows/ci.yml +89 -0
- package/vendor/re2/.github/workflows/pr.yml +26 -0
- package/vendor/re2/.github/workflows/python.yml +185 -0
- package/vendor/re2/AUTHORS +13 -0
- package/vendor/re2/BUILD.bazel +280 -0
- package/vendor/re2/CMakeLists.txt +268 -0
- package/vendor/re2/CONTRIBUTING.md +2 -0
- package/vendor/re2/CONTRIBUTORS +41 -0
- package/vendor/re2/Makefile +400 -0
- package/vendor/{README → re2/README} +5 -0
- package/vendor/re2/SECURITY.md +4 -0
- package/vendor/re2/WORKSPACE.bazel +62 -0
- package/vendor/re2/app/BUILD.bazel +19 -0
- package/vendor/re2/app/_re2.cc +94 -0
- package/vendor/re2/app/_re2.d.ts +23 -0
- package/vendor/re2/app/app.ts +111 -0
- package/vendor/re2/app/build.sh +50 -0
- package/vendor/re2/app/index.html +5 -0
- package/vendor/re2/app/package.json +14 -0
- package/vendor/re2/app/rollup.config.js +28 -0
- package/vendor/re2/app/tsconfig.json +17 -0
- package/vendor/re2/benchlog/benchplot.py +98 -0
- package/vendor/re2/benchlog/mktable +155 -0
- package/vendor/re2/doc/mksyntaxgo +42 -0
- package/vendor/re2/doc/mksyntaxhtml +42 -0
- package/vendor/re2/doc/mksyntaxwiki +36 -0
- package/vendor/re2/doc/syntax.html +477 -0
- package/vendor/re2/doc/syntax.txt +463 -0
- package/vendor/re2/lib/git/commit-msg.hook +104 -0
- package/vendor/re2/libre2.symbols +19 -0
- package/vendor/re2/libre2.symbols.darwin +15 -0
- package/vendor/re2/python/BUILD.bazel +36 -0
- package/vendor/re2/python/README +1 -0
- package/vendor/re2/python/_re2.cc +338 -0
- package/vendor/re2/python/re2.py +582 -0
- package/vendor/re2/python/re2_test.py +482 -0
- package/vendor/re2/python/setup.py +105 -0
- package/vendor/re2/{bitmap256.cc → re2/bitmap256.cc} +4 -4
- package/vendor/re2/{bitstate.cc → re2/bitstate.cc} +21 -25
- package/vendor/re2/{compile.cc → re2/compile.cc} +5 -4
- package/vendor/re2/{dfa.cc → re2/dfa.cc} +120 -101
- package/vendor/re2/{filtered_re2.cc → re2/filtered_re2.cc} +8 -11
- package/vendor/re2/{filtered_re2.h → re2/filtered_re2.h} +5 -4
- package/vendor/re2/{fuzzing → re2/fuzzing}/re2_fuzzer.cc +4 -6
- package/vendor/re2/{mimics_pcre.cc → re2/mimics_pcre.cc} +0 -1
- package/vendor/re2/{nfa.cc → re2/nfa.cc} +34 -37
- package/vendor/re2/{onepass.cc → re2/onepass.cc} +25 -27
- package/vendor/re2/{parse.cc → re2/parse.cc} +118 -121
- package/vendor/re2/{prefilter.cc → re2/prefilter.cc} +2 -3
- package/vendor/re2/{prefilter.h → re2/prefilter.h} +0 -1
- package/vendor/re2/{prefilter_tree.cc → re2/prefilter_tree.cc} +4 -5
- package/vendor/re2/{prefilter_tree.h → re2/prefilter_tree.h} +1 -2
- package/vendor/re2/{prog.cc → re2/prog.cc} +20 -21
- package/vendor/re2/{prog.h → re2/prog.h} +21 -22
- package/vendor/re2/{re2.cc → re2/re2.cc} +51 -62
- package/vendor/re2/{re2.h → re2/re2.h} +78 -40
- package/vendor/re2/{regexp.cc → re2/regexp.cc} +11 -12
- package/vendor/re2/{regexp.h → re2/regexp.h} +9 -10
- package/vendor/re2/{set.cc → re2/set.cc} +3 -5
- package/vendor/re2/{set.h → re2/set.h} +4 -3
- package/vendor/re2/{simplify.cc → re2/simplify.cc} +1 -2
- package/vendor/re2/re2/stringpiece.h +24 -0
- package/vendor/re2/{testing → re2/testing}/backtrack.cc +22 -25
- package/vendor/re2/{testing → re2/testing}/charclass_test.cc +23 -21
- package/vendor/re2/{testing → re2/testing}/compile_test.cc +5 -4
- package/vendor/re2/{testing → re2/testing}/dfa_test.cc +36 -30
- package/vendor/re2/{testing → re2/testing}/dump.cc +8 -8
- package/vendor/re2/{testing → re2/testing}/exhaustive1_test.cc +1 -1
- package/vendor/re2/{testing → re2/testing}/exhaustive2_test.cc +1 -1
- package/vendor/re2/{testing → re2/testing}/exhaustive3_test.cc +1 -1
- package/vendor/re2/{testing → re2/testing}/exhaustive_test.cc +1 -1
- package/vendor/re2/{testing → re2/testing}/exhaustive_tester.cc +36 -32
- package/vendor/re2/{testing → re2/testing}/exhaustive_tester.h +0 -1
- package/vendor/re2/{testing → re2/testing}/filtered_re2_test.cc +9 -8
- package/vendor/re2/{testing → re2/testing}/mimics_pcre_test.cc +3 -2
- package/vendor/re2/{testing → re2/testing}/null_walker.cc +1 -1
- package/vendor/re2/{testing → re2/testing}/parse_test.cc +13 -12
- package/vendor/re2/{testing → re2/testing}/possible_match_test.cc +15 -14
- package/vendor/re2/{testing → re2/testing}/random_test.cc +13 -12
- package/vendor/re2/{testing → re2/testing}/re2_arg_test.cc +25 -2
- package/vendor/re2/{testing → re2/testing}/re2_test.cc +49 -47
- package/vendor/re2/{testing → re2/testing}/regexp_benchmark.cc +144 -145
- package/vendor/re2/{testing → re2/testing}/regexp_generator.cc +18 -14
- package/vendor/re2/{testing → re2/testing}/regexp_generator.h +3 -4
- package/vendor/re2/{testing → re2/testing}/regexp_test.cc +1 -1
- package/vendor/re2/{testing → re2/testing}/required_prefix_test.cc +5 -4
- package/vendor/re2/{testing → re2/testing}/search_test.cc +3 -2
- package/vendor/re2/{testing → re2/testing}/set_test.cc +1 -1
- package/vendor/re2/{testing → re2/testing}/simplify_test.cc +3 -2
- package/vendor/re2/{testing → re2/testing}/string_generator.cc +3 -3
- package/vendor/re2/{testing → re2/testing}/string_generator.h +5 -6
- package/vendor/re2/{testing → re2/testing}/string_generator_test.cc +2 -2
- package/vendor/re2/{testing → re2/testing}/tester.cc +77 -78
- package/vendor/re2/{testing → re2/testing}/tester.h +13 -15
- package/vendor/re2/{tostring.cc → re2/tostring.cc} +7 -8
- package/vendor/re2/{unicode_casefold.h → re2/unicode_casefold.h} +0 -1
- package/vendor/re2/{unicode_groups.h → re2/unicode_groups.h} +0 -1
- package/vendor/re2/{walker-inl.h → re2/walker-inl.h} +2 -1
- package/vendor/re2/re2.pc.in +9 -0
- package/vendor/re2/re2Config.cmake.in +28 -0
- package/vendor/re2/runtests +33 -0
- package/vendor/re2/testinstall.cc +27 -0
- package/vendor/re2/ucs2.diff +567 -0
- package/vendor/{util → re2/util}/logging.h +2 -2
- package/vendor/{util → re2/util}/pcre.cc +47 -116
- package/vendor/{util → re2/util}/pcre.h +53 -63
- package/vendor/re2/util/strutil.cc +26 -0
- package/vendor/{util → re2/util}/strutil.h +0 -5
- package/vendor/re2/stringpiece.cc +0 -65
- package/vendor/re2/stringpiece.h +0 -213
- package/vendor/util/benchmark.cc +0 -131
- package/vendor/util/benchmark.h +0 -156
- package/vendor/util/flags.h +0 -26
- package/vendor/util/mix.h +0 -41
- package/vendor/util/mutex.h +0 -164
- package/vendor/util/strutil.cc +0 -149
- package/vendor/util/test.cc +0 -34
- package/vendor/util/test.h +0 -50
- package/vendor/util/util.h +0 -42
- /package/vendor/{LICENSE → re2/LICENSE} +0 -0
- /package/vendor/re2/{bitmap256.h → re2/bitmap256.h} +0 -0
- /package/vendor/re2/{fuzzing → re2/fuzzing}/compiler-rt/LICENSE +0 -0
- /package/vendor/re2/{fuzzing → re2/fuzzing}/compiler-rt/include/fuzzer/FuzzedDataProvider.h +0 -0
- /package/vendor/re2/{make_perl_groups.pl → re2/make_perl_groups.pl} +0 -0
- /package/vendor/re2/{make_unicode_casefold.py → re2/make_unicode_casefold.py} +0 -0
- /package/vendor/re2/{make_unicode_groups.py → re2/make_unicode_groups.py} +0 -0
- /package/vendor/re2/{perl_groups.cc → re2/perl_groups.cc} +0 -0
- /package/vendor/re2/{pod_array.h → re2/pod_array.h} +0 -0
- /package/vendor/re2/{sparse_array.h → re2/sparse_array.h} +0 -0
- /package/vendor/re2/{sparse_set.h → re2/sparse_set.h} +0 -0
- /package/vendor/re2/{unicode.py → re2/unicode.py} +0 -0
- /package/vendor/re2/{unicode_casefold.cc → re2/unicode_casefold.cc} +0 -0
- /package/vendor/re2/{unicode_groups.cc → re2/unicode_groups.cc} +0 -0
- /package/vendor/{util → re2/util}/fuzz.cc +0 -0
- /package/vendor/{util → re2/util}/malloc_counter.h +0 -0
- /package/vendor/{util → re2/util}/rune.cc +0 -0
- /package/vendor/{util → re2/util}/utf.h +0 -0
package/vendor/re2/stringpiece.h
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
// Copyright 2001-2010 The RE2 Authors. All Rights Reserved.
|
|
2
|
-
// Use of this source code is governed by a BSD-style
|
|
3
|
-
// license that can be found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
#ifndef RE2_STRINGPIECE_H_
|
|
6
|
-
#define RE2_STRINGPIECE_H_
|
|
7
|
-
|
|
8
|
-
// A string-like object that points to a sized piece of memory.
|
|
9
|
-
//
|
|
10
|
-
// Functions or methods may use const StringPiece& parameters to accept either
|
|
11
|
-
// a "const char*" or a "string" value that will be implicitly converted to
|
|
12
|
-
// a StringPiece. The implicit conversion means that it is often appropriate
|
|
13
|
-
// to include this .h file in other files rather than forward-declaring
|
|
14
|
-
// StringPiece as would be appropriate for most other Google classes.
|
|
15
|
-
//
|
|
16
|
-
// Systematic usage of StringPiece is encouraged as it will reduce unnecessary
|
|
17
|
-
// conversions from "const char*" to "string" and back again.
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
// Arghh! I wish C++ literals were "string".
|
|
21
|
-
|
|
22
|
-
#include <stddef.h>
|
|
23
|
-
#include <string.h>
|
|
24
|
-
#include <algorithm>
|
|
25
|
-
#include <iosfwd>
|
|
26
|
-
#include <iterator>
|
|
27
|
-
#include <string>
|
|
28
|
-
#ifdef __cpp_lib_string_view
|
|
29
|
-
#include <string_view>
|
|
30
|
-
#endif
|
|
31
|
-
|
|
32
|
-
namespace re2 {
|
|
33
|
-
|
|
34
|
-
class StringPiece {
|
|
35
|
-
public:
|
|
36
|
-
typedef std::char_traits<char> traits_type;
|
|
37
|
-
typedef char value_type;
|
|
38
|
-
typedef char* pointer;
|
|
39
|
-
typedef const char* const_pointer;
|
|
40
|
-
typedef char& reference;
|
|
41
|
-
typedef const char& const_reference;
|
|
42
|
-
typedef const char* const_iterator;
|
|
43
|
-
typedef const_iterator iterator;
|
|
44
|
-
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
|
45
|
-
typedef const_reverse_iterator reverse_iterator;
|
|
46
|
-
typedef size_t size_type;
|
|
47
|
-
typedef ptrdiff_t difference_type;
|
|
48
|
-
static const size_type npos = static_cast<size_type>(-1);
|
|
49
|
-
|
|
50
|
-
// We provide non-explicit singleton constructors so users can pass
|
|
51
|
-
// in a "const char*" or a "string" wherever a "StringPiece" is
|
|
52
|
-
// expected.
|
|
53
|
-
StringPiece()
|
|
54
|
-
: data_(NULL), size_(0) {}
|
|
55
|
-
#ifdef __cpp_lib_string_view
|
|
56
|
-
StringPiece(const std::string_view& str)
|
|
57
|
-
: data_(str.data()), size_(str.size()) {}
|
|
58
|
-
#endif
|
|
59
|
-
StringPiece(const std::string& str)
|
|
60
|
-
: data_(str.data()), size_(str.size()) {}
|
|
61
|
-
StringPiece(const char* str)
|
|
62
|
-
: data_(str), size_(str == NULL ? 0 : strlen(str)) {}
|
|
63
|
-
StringPiece(const char* str, size_type len)
|
|
64
|
-
: data_(str), size_(len) {}
|
|
65
|
-
|
|
66
|
-
const_iterator begin() const { return data_; }
|
|
67
|
-
const_iterator end() const { return data_ + size_; }
|
|
68
|
-
const_reverse_iterator rbegin() const {
|
|
69
|
-
return const_reverse_iterator(data_ + size_);
|
|
70
|
-
}
|
|
71
|
-
const_reverse_iterator rend() const {
|
|
72
|
-
return const_reverse_iterator(data_);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
size_type size() const { return size_; }
|
|
76
|
-
size_type length() const { return size_; }
|
|
77
|
-
bool empty() const { return size_ == 0; }
|
|
78
|
-
|
|
79
|
-
const_reference operator[](size_type i) const { return data_[i]; }
|
|
80
|
-
const_pointer data() const { return data_; }
|
|
81
|
-
|
|
82
|
-
void remove_prefix(size_type n) {
|
|
83
|
-
data_ += n;
|
|
84
|
-
size_ -= n;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
void remove_suffix(size_type n) {
|
|
88
|
-
size_ -= n;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
void set(const char* str) {
|
|
92
|
-
data_ = str;
|
|
93
|
-
size_ = str == NULL ? 0 : strlen(str);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
void set(const char* str, size_type len) {
|
|
97
|
-
data_ = str;
|
|
98
|
-
size_ = len;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
#ifdef __cpp_lib_string_view
|
|
102
|
-
// Converts to `std::basic_string_view`.
|
|
103
|
-
operator std::basic_string_view<char, traits_type>() const {
|
|
104
|
-
if (!data_) return {};
|
|
105
|
-
return std::basic_string_view<char, traits_type>(data_, size_);
|
|
106
|
-
}
|
|
107
|
-
#endif
|
|
108
|
-
|
|
109
|
-
// Converts to `std::basic_string`.
|
|
110
|
-
template <typename A>
|
|
111
|
-
explicit operator std::basic_string<char, traits_type, A>() const {
|
|
112
|
-
if (!data_) return {};
|
|
113
|
-
return std::basic_string<char, traits_type, A>(data_, size_);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
std::string as_string() const {
|
|
117
|
-
return std::string(data_, size_);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// We also define ToString() here, since many other string-like
|
|
121
|
-
// interfaces name the routine that converts to a C++ string
|
|
122
|
-
// "ToString", and it's confusing to have the method that does that
|
|
123
|
-
// for a StringPiece be called "as_string()". We also leave the
|
|
124
|
-
// "as_string()" method defined here for existing code.
|
|
125
|
-
std::string ToString() const {
|
|
126
|
-
return std::string(data_, size_);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
void CopyToString(std::string* target) const {
|
|
130
|
-
target->assign(data_, size_);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
void AppendToString(std::string* target) const {
|
|
134
|
-
target->append(data_, size_);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
size_type copy(char* buf, size_type n, size_type pos = 0) const;
|
|
138
|
-
StringPiece substr(size_type pos = 0, size_type n = npos) const;
|
|
139
|
-
|
|
140
|
-
int compare(const StringPiece& x) const {
|
|
141
|
-
size_type min_size = std::min(size(), x.size());
|
|
142
|
-
if (min_size > 0) {
|
|
143
|
-
int r = memcmp(data(), x.data(), min_size);
|
|
144
|
-
if (r < 0) return -1;
|
|
145
|
-
if (r > 0) return 1;
|
|
146
|
-
}
|
|
147
|
-
if (size() < x.size()) return -1;
|
|
148
|
-
if (size() > x.size()) return 1;
|
|
149
|
-
return 0;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// Does "this" start with "x"?
|
|
153
|
-
bool starts_with(const StringPiece& x) const {
|
|
154
|
-
return x.empty() ||
|
|
155
|
-
(size() >= x.size() && memcmp(data(), x.data(), x.size()) == 0);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// Does "this" end with "x"?
|
|
159
|
-
bool ends_with(const StringPiece& x) const {
|
|
160
|
-
return x.empty() ||
|
|
161
|
-
(size() >= x.size() &&
|
|
162
|
-
memcmp(data() + (size() - x.size()), x.data(), x.size()) == 0);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
bool contains(const StringPiece& s) const {
|
|
166
|
-
return find(s) != npos;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
size_type find(const StringPiece& s, size_type pos = 0) const;
|
|
170
|
-
size_type find(char c, size_type pos = 0) const;
|
|
171
|
-
size_type rfind(const StringPiece& s, size_type pos = npos) const;
|
|
172
|
-
size_type rfind(char c, size_type pos = npos) const;
|
|
173
|
-
|
|
174
|
-
private:
|
|
175
|
-
const_pointer data_;
|
|
176
|
-
size_type size_;
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
inline bool operator==(const StringPiece& x, const StringPiece& y) {
|
|
180
|
-
StringPiece::size_type len = x.size();
|
|
181
|
-
if (len != y.size()) return false;
|
|
182
|
-
return x.data() == y.data() || len == 0 ||
|
|
183
|
-
memcmp(x.data(), y.data(), len) == 0;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
inline bool operator!=(const StringPiece& x, const StringPiece& y) {
|
|
187
|
-
return !(x == y);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
inline bool operator<(const StringPiece& x, const StringPiece& y) {
|
|
191
|
-
StringPiece::size_type min_size = std::min(x.size(), y.size());
|
|
192
|
-
int r = min_size == 0 ? 0 : memcmp(x.data(), y.data(), min_size);
|
|
193
|
-
return (r < 0) || (r == 0 && x.size() < y.size());
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
inline bool operator>(const StringPiece& x, const StringPiece& y) {
|
|
197
|
-
return y < x;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
inline bool operator<=(const StringPiece& x, const StringPiece& y) {
|
|
201
|
-
return !(x > y);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
inline bool operator>=(const StringPiece& x, const StringPiece& y) {
|
|
205
|
-
return !(x < y);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// Allow StringPiece to be logged.
|
|
209
|
-
std::ostream& operator<<(std::ostream& o, const StringPiece& p);
|
|
210
|
-
|
|
211
|
-
} // namespace re2
|
|
212
|
-
|
|
213
|
-
#endif // RE2_STRINGPIECE_H_
|
package/vendor/util/benchmark.cc
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
// Copyright 2009 The RE2 Authors. All Rights Reserved.
|
|
2
|
-
// Use of this source code is governed by a BSD-style
|
|
3
|
-
// license that can be found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
#include <stdint.h>
|
|
6
|
-
#include <stdio.h>
|
|
7
|
-
#include <stdlib.h>
|
|
8
|
-
#include <algorithm>
|
|
9
|
-
#include <chrono>
|
|
10
|
-
|
|
11
|
-
#include "util/benchmark.h"
|
|
12
|
-
#include "util/flags.h"
|
|
13
|
-
#include "re2/re2.h"
|
|
14
|
-
|
|
15
|
-
#ifdef _WIN32
|
|
16
|
-
#define snprintf _snprintf
|
|
17
|
-
#endif
|
|
18
|
-
|
|
19
|
-
using ::testing::Benchmark;
|
|
20
|
-
|
|
21
|
-
static Benchmark* benchmarks[10000];
|
|
22
|
-
static int nbenchmarks;
|
|
23
|
-
|
|
24
|
-
void Benchmark::Register() {
|
|
25
|
-
lo_ = std::max(1, lo_);
|
|
26
|
-
hi_ = std::max(lo_, hi_);
|
|
27
|
-
benchmarks[nbenchmarks++] = this;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static int64_t nsec() {
|
|
31
|
-
return std::chrono::duration_cast<std::chrono::nanoseconds>(
|
|
32
|
-
std::chrono::steady_clock::now().time_since_epoch())
|
|
33
|
-
.count();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
static int64_t t0;
|
|
37
|
-
static int64_t ns;
|
|
38
|
-
static int64_t bytes;
|
|
39
|
-
static int64_t items;
|
|
40
|
-
|
|
41
|
-
void StartBenchmarkTiming() {
|
|
42
|
-
if (t0 == 0) {
|
|
43
|
-
t0 = nsec();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
void StopBenchmarkTiming() {
|
|
48
|
-
if (t0 != 0) {
|
|
49
|
-
ns += nsec() - t0;
|
|
50
|
-
t0 = 0;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
void SetBenchmarkBytesProcessed(int64_t b) { bytes = b; }
|
|
55
|
-
|
|
56
|
-
void SetBenchmarkItemsProcessed(int64_t i) { items = i; }
|
|
57
|
-
|
|
58
|
-
static void RunFunc(Benchmark* b, int iters, int arg) {
|
|
59
|
-
t0 = nsec();
|
|
60
|
-
ns = 0;
|
|
61
|
-
bytes = 0;
|
|
62
|
-
items = 0;
|
|
63
|
-
b->func()(iters, arg);
|
|
64
|
-
StopBenchmarkTiming();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
static int round(int n) {
|
|
68
|
-
int base = 1;
|
|
69
|
-
while (base * 10 < n) base *= 10;
|
|
70
|
-
if (n < 2 * base) return 2 * base;
|
|
71
|
-
if (n < 5 * base) return 5 * base;
|
|
72
|
-
return 10 * base;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
static void RunBench(Benchmark* b, int arg) {
|
|
76
|
-
int iters, last;
|
|
77
|
-
|
|
78
|
-
// Run once just in case it's expensive.
|
|
79
|
-
iters = 1;
|
|
80
|
-
RunFunc(b, iters, arg);
|
|
81
|
-
while (ns < (int)1e9 && iters < (int)1e9) {
|
|
82
|
-
last = iters;
|
|
83
|
-
if (ns / iters == 0) {
|
|
84
|
-
iters = (int)1e9;
|
|
85
|
-
} else {
|
|
86
|
-
iters = (int)1e9 / static_cast<int>(ns / iters);
|
|
87
|
-
}
|
|
88
|
-
iters = std::max(last + 1, std::min(iters + iters / 2, 100 * last));
|
|
89
|
-
iters = round(iters);
|
|
90
|
-
RunFunc(b, iters, arg);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
char mb[100];
|
|
94
|
-
char suf[100];
|
|
95
|
-
mb[0] = '\0';
|
|
96
|
-
suf[0] = '\0';
|
|
97
|
-
if (ns > 0 && bytes > 0)
|
|
98
|
-
snprintf(mb, sizeof mb, "\t%7.2f MB/s",
|
|
99
|
-
((double)bytes / 1e6) / ((double)ns / 1e9));
|
|
100
|
-
if (b->has_arg()) {
|
|
101
|
-
if (arg >= (1 << 20)) {
|
|
102
|
-
snprintf(suf, sizeof suf, "/%dM", arg / (1 << 20));
|
|
103
|
-
} else if (arg >= (1 << 10)) {
|
|
104
|
-
snprintf(suf, sizeof suf, "/%dK", arg / (1 << 10));
|
|
105
|
-
} else {
|
|
106
|
-
snprintf(suf, sizeof suf, "/%d", arg);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
printf("%s%s\t%8d\t%10lld ns/op%s\n", b->name(), suf, iters,
|
|
110
|
-
(long long)ns / iters, mb);
|
|
111
|
-
fflush(stdout);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
static bool WantBench(const char* name, int argc, const char** argv) {
|
|
115
|
-
if (argc == 1) return true;
|
|
116
|
-
for (int i = 1; i < argc; i++) {
|
|
117
|
-
if (RE2::PartialMatch(name, argv[i]))
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
int main(int argc, const char** argv) {
|
|
124
|
-
for (int i = 0; i < nbenchmarks; i++) {
|
|
125
|
-
Benchmark* b = benchmarks[i];
|
|
126
|
-
if (!WantBench(b->name(), argc, argv))
|
|
127
|
-
continue;
|
|
128
|
-
for (int arg = b->lo(); arg <= b->hi(); arg <<= 1)
|
|
129
|
-
RunBench(b, arg);
|
|
130
|
-
}
|
|
131
|
-
}
|
package/vendor/util/benchmark.h
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
// Copyright 2009 The RE2 Authors. All Rights Reserved.
|
|
2
|
-
// Use of this source code is governed by a BSD-style
|
|
3
|
-
// license that can be found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
#ifndef UTIL_BENCHMARK_H_
|
|
6
|
-
#define UTIL_BENCHMARK_H_
|
|
7
|
-
|
|
8
|
-
#include <stdint.h>
|
|
9
|
-
#include <functional>
|
|
10
|
-
|
|
11
|
-
#include "util/logging.h"
|
|
12
|
-
#include "util/util.h"
|
|
13
|
-
|
|
14
|
-
// Globals for the old benchmark API.
|
|
15
|
-
void StartBenchmarkTiming();
|
|
16
|
-
void StopBenchmarkTiming();
|
|
17
|
-
void SetBenchmarkBytesProcessed(int64_t b);
|
|
18
|
-
void SetBenchmarkItemsProcessed(int64_t i);
|
|
19
|
-
|
|
20
|
-
namespace benchmark {
|
|
21
|
-
|
|
22
|
-
// The new benchmark API implemented as a layer over the old benchmark API.
|
|
23
|
-
// (Please refer to https://github.com/google/benchmark for documentation.)
|
|
24
|
-
class State {
|
|
25
|
-
private:
|
|
26
|
-
class Iterator {
|
|
27
|
-
public:
|
|
28
|
-
// Benchmark code looks like this:
|
|
29
|
-
//
|
|
30
|
-
// for (auto _ : state) {
|
|
31
|
-
// // ...
|
|
32
|
-
// }
|
|
33
|
-
//
|
|
34
|
-
// We try to avoid compiler warnings about such variables being unused.
|
|
35
|
-
struct ATTRIBUTE_UNUSED Value {};
|
|
36
|
-
|
|
37
|
-
explicit Iterator(int64_t iters) : iters_(iters) {}
|
|
38
|
-
|
|
39
|
-
bool operator!=(const Iterator& that) const {
|
|
40
|
-
if (iters_ != that.iters_) {
|
|
41
|
-
return true;
|
|
42
|
-
} else {
|
|
43
|
-
// We are about to stop the loop, so stop timing.
|
|
44
|
-
StopBenchmarkTiming();
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
Value operator*() const {
|
|
50
|
-
return Value();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
Iterator& operator++() {
|
|
54
|
-
--iters_;
|
|
55
|
-
return *this;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
private:
|
|
59
|
-
int64_t iters_;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
public:
|
|
63
|
-
explicit State(int64_t iters)
|
|
64
|
-
: iters_(iters), arg_(0), has_arg_(false) {}
|
|
65
|
-
|
|
66
|
-
State(int64_t iters, int64_t arg)
|
|
67
|
-
: iters_(iters), arg_(arg), has_arg_(true) {}
|
|
68
|
-
|
|
69
|
-
Iterator begin() {
|
|
70
|
-
// We are about to start the loop, so start timing.
|
|
71
|
-
StartBenchmarkTiming();
|
|
72
|
-
return Iterator(iters_);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
Iterator end() {
|
|
76
|
-
return Iterator(0);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
void SetBytesProcessed(int64_t b) { SetBenchmarkBytesProcessed(b); }
|
|
80
|
-
void SetItemsProcessed(int64_t i) { SetBenchmarkItemsProcessed(i); }
|
|
81
|
-
int64_t iterations() const { return iters_; }
|
|
82
|
-
// Pretend to support multiple arguments.
|
|
83
|
-
int64_t range(int pos) const { CHECK(has_arg_); return arg_; }
|
|
84
|
-
|
|
85
|
-
private:
|
|
86
|
-
int64_t iters_;
|
|
87
|
-
int64_t arg_;
|
|
88
|
-
bool has_arg_;
|
|
89
|
-
|
|
90
|
-
State(const State&) = delete;
|
|
91
|
-
State& operator=(const State&) = delete;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
} // namespace benchmark
|
|
95
|
-
|
|
96
|
-
namespace testing {
|
|
97
|
-
|
|
98
|
-
class Benchmark {
|
|
99
|
-
public:
|
|
100
|
-
Benchmark(const char* name, void (*func)(benchmark::State&))
|
|
101
|
-
: name_(name),
|
|
102
|
-
func_([func](int iters, int arg) {
|
|
103
|
-
benchmark::State state(iters);
|
|
104
|
-
func(state);
|
|
105
|
-
}),
|
|
106
|
-
lo_(0),
|
|
107
|
-
hi_(0),
|
|
108
|
-
has_arg_(false) {
|
|
109
|
-
Register();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
Benchmark(const char* name, void (*func)(benchmark::State&), int lo, int hi)
|
|
113
|
-
: name_(name),
|
|
114
|
-
func_([func](int iters, int arg) {
|
|
115
|
-
benchmark::State state(iters, arg);
|
|
116
|
-
func(state);
|
|
117
|
-
}),
|
|
118
|
-
lo_(lo),
|
|
119
|
-
hi_(hi),
|
|
120
|
-
has_arg_(true) {
|
|
121
|
-
Register();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// Pretend to support multiple threads.
|
|
125
|
-
Benchmark* ThreadRange(int lo, int hi) { return this; }
|
|
126
|
-
|
|
127
|
-
const char* name() const { return name_; }
|
|
128
|
-
const std::function<void(int, int)>& func() const { return func_; }
|
|
129
|
-
int lo() const { return lo_; }
|
|
130
|
-
int hi() const { return hi_; }
|
|
131
|
-
bool has_arg() const { return has_arg_; }
|
|
132
|
-
|
|
133
|
-
private:
|
|
134
|
-
void Register();
|
|
135
|
-
|
|
136
|
-
const char* name_;
|
|
137
|
-
std::function<void(int, int)> func_;
|
|
138
|
-
int lo_;
|
|
139
|
-
int hi_;
|
|
140
|
-
bool has_arg_;
|
|
141
|
-
|
|
142
|
-
Benchmark(const Benchmark&) = delete;
|
|
143
|
-
Benchmark& operator=(const Benchmark&) = delete;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
} // namespace testing
|
|
147
|
-
|
|
148
|
-
#define BENCHMARK(f) \
|
|
149
|
-
::testing::Benchmark* _benchmark_##f = \
|
|
150
|
-
(new ::testing::Benchmark(#f, f))
|
|
151
|
-
|
|
152
|
-
#define BENCHMARK_RANGE(f, lo, hi) \
|
|
153
|
-
::testing::Benchmark* _benchmark_##f = \
|
|
154
|
-
(new ::testing::Benchmark(#f, f, lo, hi))
|
|
155
|
-
|
|
156
|
-
#endif // UTIL_BENCHMARK_H_
|
package/vendor/util/flags.h
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// Copyright 2009 The RE2 Authors. All Rights Reserved.
|
|
2
|
-
// Use of this source code is governed by a BSD-style
|
|
3
|
-
// license that can be found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
#ifndef UTIL_FLAGS_H_
|
|
6
|
-
#define UTIL_FLAGS_H_
|
|
7
|
-
|
|
8
|
-
// Simplified version of Google's command line flags.
|
|
9
|
-
// Does not support parsing the command line.
|
|
10
|
-
// If you want to do that, see
|
|
11
|
-
// https://gflags.github.io/gflags/
|
|
12
|
-
|
|
13
|
-
#define DEFINE_FLAG(type, name, deflt, desc) \
|
|
14
|
-
namespace re2 { type FLAGS_##name = deflt; }
|
|
15
|
-
|
|
16
|
-
#define DECLARE_FLAG(type, name) \
|
|
17
|
-
namespace re2 { extern type FLAGS_##name; }
|
|
18
|
-
|
|
19
|
-
namespace re2 {
|
|
20
|
-
template <typename T>
|
|
21
|
-
T GetFlag(const T& flag) {
|
|
22
|
-
return flag;
|
|
23
|
-
}
|
|
24
|
-
} // namespace re2
|
|
25
|
-
|
|
26
|
-
#endif // UTIL_FLAGS_H_
|
package/vendor/util/mix.h
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// Copyright 2016 The RE2 Authors. All Rights Reserved.
|
|
2
|
-
// Use of this source code is governed by a BSD-style
|
|
3
|
-
// license that can be found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
#ifndef UTIL_MIX_H_
|
|
6
|
-
#define UTIL_MIX_H_
|
|
7
|
-
|
|
8
|
-
#include <stddef.h>
|
|
9
|
-
#include <limits>
|
|
10
|
-
|
|
11
|
-
namespace re2 {
|
|
12
|
-
|
|
13
|
-
// Silence "truncation of constant value" warning for kMul in 32-bit mode.
|
|
14
|
-
// Since this is a header file, push and then pop to limit the scope.
|
|
15
|
-
#ifdef _MSC_VER
|
|
16
|
-
#pragma warning(push)
|
|
17
|
-
#pragma warning(disable: 4309)
|
|
18
|
-
#endif
|
|
19
|
-
|
|
20
|
-
class HashMix {
|
|
21
|
-
public:
|
|
22
|
-
HashMix() : hash_(1) {}
|
|
23
|
-
explicit HashMix(size_t val) : hash_(val + 83) {}
|
|
24
|
-
void Mix(size_t val) {
|
|
25
|
-
static const size_t kMul = static_cast<size_t>(0xdc3eb94af8ab4c93ULL);
|
|
26
|
-
hash_ *= kMul;
|
|
27
|
-
hash_ = ((hash_ << 19) |
|
|
28
|
-
(hash_ >> (std::numeric_limits<size_t>::digits - 19))) + val;
|
|
29
|
-
}
|
|
30
|
-
size_t get() const { return hash_; }
|
|
31
|
-
private:
|
|
32
|
-
size_t hash_;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
#ifdef _MSC_VER
|
|
36
|
-
#pragma warning(pop)
|
|
37
|
-
#endif
|
|
38
|
-
|
|
39
|
-
} // namespace re2
|
|
40
|
-
|
|
41
|
-
#endif // UTIL_MIX_H_
|