| 1777 | } |
| 1778 | |
| 1779 | DFA* Prog::GetDFA(MatchKind kind) { |
| 1780 | // For a forward DFA, half the memory goes to each DFA. |
| 1781 | // However, if it is a "many match" DFA, then there is |
| 1782 | // no counterpart with which the memory must be shared. |
| 1783 | // |
| 1784 | // For a reverse DFA, all the memory goes to the |
| 1785 | // "longest match" DFA, because RE2 never does reverse |
| 1786 | // "first match" searches. |
| 1787 | if (kind == kFirstMatch) { |
| 1788 | std::call_once(dfa_first_once_, [](Prog* prog) { |
| 1789 | prog->dfa_first_ = new DFA(prog, kFirstMatch, prog->dfa_mem_ / 2); |
| 1790 | }, this); |
| 1791 | return dfa_first_; |
| 1792 | } else if (kind == kManyMatch) { |
| 1793 | std::call_once(dfa_first_once_, [](Prog* prog) { |
| 1794 | prog->dfa_first_ = new DFA(prog, kManyMatch, prog->dfa_mem_); |
| 1795 | }, this); |
| 1796 | return dfa_first_; |
| 1797 | } else { |
| 1798 | std::call_once(dfa_longest_once_, [](Prog* prog) { |
| 1799 | if (!prog->reversed_) |
| 1800 | prog->dfa_longest_ = new DFA(prog, kLongestMatch, prog->dfa_mem_ / 2); |
| 1801 | else |
| 1802 | prog->dfa_longest_ = new DFA(prog, kLongestMatch, prog->dfa_mem_); |
| 1803 | }, this); |
| 1804 | return dfa_longest_; |
| 1805 | } |
| 1806 | } |
| 1807 | |
| 1808 | void Prog::DeleteDFA(DFA* dfa) { |
| 1809 | delete dfa; |
nothing calls this directly
no test coverage detected