| 175 | // Caller must Decref() return value when done with it. |
| 176 | |
| 177 | Regexp* Regexp::Simplify() { |
| 178 | CoalesceWalker cw; |
| 179 | Regexp* cre = cw.Walk(this, NULL); |
| 180 | if (cre == NULL) |
| 181 | return NULL; |
| 182 | if (cw.stopped_early()) { |
| 183 | cre->Decref(); |
| 184 | return NULL; |
| 185 | } |
| 186 | SimplifyWalker sw; |
| 187 | Regexp* sre = sw.Walk(cre, NULL); |
| 188 | cre->Decref(); |
| 189 | if (sre == NULL) |
| 190 | return NULL; |
| 191 | if (sw.stopped_early()) { |
| 192 | sre->Decref(); |
| 193 | return NULL; |
| 194 | } |
| 195 | return sre; |
| 196 | } |
| 197 | |
| 198 | #define Simplify DontCallSimplify // Avoid accidental recursion |
| 199 | |