MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / DoCoalesce

Method DoCoalesce

extern/re2/re2/simplify.cc:345–442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

343}
344
345void CoalesceWalker::DoCoalesce(Regexp** r1ptr, Regexp** r2ptr) {
346 Regexp* r1 = *r1ptr;
347 Regexp* r2 = *r2ptr;
348
349 Regexp* nre = Regexp::Repeat(
350 r1->sub()[0]->Incref(), r1->parse_flags(), 0, 0);
351
352 switch (r1->op()) {
353 case kRegexpStar:
354 nre->min_ = 0;
355 nre->max_ = -1;
356 break;
357
358 case kRegexpPlus:
359 nre->min_ = 1;
360 nre->max_ = -1;
361 break;
362
363 case kRegexpQuest:
364 nre->min_ = 0;
365 nre->max_ = 1;
366 break;
367
368 case kRegexpRepeat:
369 nre->min_ = r1->min();
370 nre->max_ = r1->max();
371 break;
372
373 default:
374 LOG(DFATAL) << "DoCoalesce failed: r1->op() is " << r1->op();
375 nre->Decref();
376 return;
377 }
378
379 switch (r2->op()) {
380 case kRegexpStar:
381 nre->max_ = -1;
382 goto LeaveEmpty;
383
384 case kRegexpPlus:
385 nre->min_++;
386 nre->max_ = -1;
387 goto LeaveEmpty;
388
389 case kRegexpQuest:
390 if (nre->max() != -1)
391 nre->max_++;
392 goto LeaveEmpty;
393
394 case kRegexpRepeat:
395 nre->min_ += r2->min();
396 if (r2->max() == -1)
397 nre->max_ = -1;
398 else if (nre->max() != -1)
399 nre->max_ += r2->max();
400 goto LeaveEmpty;
401
402 case kRegexpLiteral:

Callers

nothing calls this directly

Calls 10

parse_flagsMethod · 0.80
minMethod · 0.80
maxMethod · 0.80
runeMethod · 0.80
nrunesMethod · 0.80
runesMethod · 0.80
IncrefMethod · 0.45
subMethod · 0.45
opMethod · 0.45
DecrefMethod · 0.45

Tested by

no test coverage detected