Utility function for PostVisit implementations that compares re->sub() with child_args to determine whether any child_args changed. In the common case, where nothing changed, calls Decref() for all child_args and returns false, so PostVisit must return re->Incref(). Otherwise, returns true.
| 202 | // where nothing changed, calls Decref() for all child_args and returns false, |
| 203 | // so PostVisit must return re->Incref(). Otherwise, returns true. |
| 204 | static bool ChildArgsChanged(Regexp* re, Regexp** child_args) { |
| 205 | for (int i = 0; i < re->nsub(); i++) { |
| 206 | Regexp* sub = re->sub()[i]; |
| 207 | Regexp* newsub = child_args[i]; |
| 208 | if (newsub != sub) |
| 209 | return true; |
| 210 | } |
| 211 | for (int i = 0; i < re->nsub(); i++) { |
| 212 | Regexp* newsub = child_args[i]; |
| 213 | newsub->Decref(); |
| 214 | } |
| 215 | return false; |
| 216 | } |
| 217 | |
| 218 | Regexp* CoalesceWalker::Copy(Regexp* re) { |
| 219 | return re->Incref(); |