File: use-re2-instead-of-std-regex.patch

package info (click to toggle)
chromium 120.0.6099.224-1~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 6,112,112 kB
  • sloc: cpp: 32,907,025; ansic: 8,148,123; javascript: 3,679,536; python: 2,031,248; asm: 959,718; java: 804,675; xml: 617,256; sh: 111,417; objc: 100,835; perl: 88,443; cs: 53,032; makefile: 29,579; fortran: 24,137; php: 21,162; tcl: 21,147; sql: 20,809; ruby: 17,735; pascal: 12,864; yacc: 8,045; lisp: 3,388; lex: 1,323; ada: 727; awk: 329; jsp: 267; csh: 117; exp: 43; sed: 37
file content (65 lines) | stat: -rw-r--r-- 2,010 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
From b7928899936522b3d03aef1cca566030510f6a01 Mon Sep 17 00:00:00 2001
From: Robert Ogden <robertogden@chromium.org>
Date: Wed, 26 Jul 2023 11:24:47 -0700
Subject: [PATCH] use re2 instead of std regex

---
 .../src/mediapipe/framework/deps/re2.h        | 42 ++-----------------
 1 file changed, 3 insertions(+), 39 deletions(-)

diff --git a/third_party/mediapipe/src/mediapipe/framework/deps/re2.h b/third_party/mediapipe/src/mediapipe/framework/deps/re2.h
index 61f7985ee62fe..4079d9c0d1916 100644
--- a/third_party/mediapipe/src/mediapipe/framework/deps/re2.h
+++ b/third_party/mediapipe/src/mediapipe/framework/deps/re2.h
@@ -15,45 +15,9 @@
 #ifndef MEDIAPIPE_FRAMEWORK_DEPS_RE2_H_
 #define MEDIAPIPE_FRAMEWORK_DEPS_RE2_H_
 
-#include <regex>  // NOLINT
+#include "re2/re2.h"
 
-namespace mediapipe {
-
-// Implements a subset of RE2 using std::regex_match.
-class RE2 {
- public:
-  RE2(const std::string& pattern) : std_regex_(pattern) {}
-  static bool FullMatch(std::string text, const RE2& re) {
-    return std::regex_match(text, re.std_regex_);
-  }
-  static bool PartialMatch(std::string text, const RE2& re) {
-    return std::regex_search(text, re.std_regex_);
-  }
-  static int GlobalReplace(std::string* text, const RE2& re,
-                           const std::string& rewrite) {
-    std::smatch sm;
-    std::regex_search(*text, sm, re.std_regex_);
-    *text = std::regex_replace(*text, re.std_regex_, rewrite);
-    return std::max(0, static_cast<int>(sm.size()) - 1);
-  }
-
- private:
-  std::regex std_regex_;
-};
-
-// Implements LazyRE2 using std::call_once.
-class LazyRE2 {
- public:
-  RE2& operator*() const {
-    std::call_once(once_, [&]() { ptr_ = new RE2(pattern_); });
-    return *ptr_;
-  }
-  RE2* operator->() const { return &**this; }
-  const char* pattern_;
-  mutable RE2* ptr_;
-  mutable std::once_flag once_;
-};
-
-}  // namespace mediapipe
+using re2::LazyRE2;
+using re2::RE2;
 
 #endif  // MEDIAPIPE_FRAMEWORK_DEPS_RE2_H_
-- 
2.41.0.487.g6d72f3e995-goog