| 942 | // search time without the per-regexp overhead. |
| 943 | |
| 944 | Prog* GetCachedProg(const char* regexp) { |
| 945 | static auto& mutex = *new Mutex; |
| 946 | MutexLock lock(&mutex); |
| 947 | static auto& cache = *new std::unordered_map<std::string, Prog*>; |
| 948 | Prog* prog = cache[regexp]; |
| 949 | if (prog == NULL) { |
| 950 | Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); |
| 951 | CHECK(re); |
| 952 | prog = re->CompileToProg(int64_t{1}<<31); // mostly for the DFA |
| 953 | CHECK(prog); |
| 954 | cache[regexp] = prog; |
| 955 | re->Decref(); |
| 956 | } |
| 957 | return prog; |
| 958 | } |
| 959 | |
| 960 | PCRE* GetCachedPCRE(const char* regexp) { |
| 961 | static auto& mutex = *new Mutex; |
no test coverage detected