Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit ed4e437

Browse files
authored
Merge pull request #1801 from schveiguy/useboolminfo
Clean up awkward inner function for cycle sorting. merged-on-behalf-of: Iain Buclaw <ibuclaw@gdcproject.org>
2 parents eb58dcb + 13ffd4e commit ed4e437

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

src/rt/minfo.d

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -460,12 +460,9 @@ struct ModuleGroup
460460
return true;
461461
}
462462

463-
// `cycle` is set to `true` if deprecated cycle error otherwise set `result`.
464-
void doSort(size_t relevantFlags, ref bool cycle, ref immutable(ModuleInfo)*[] result)
463+
// returns `false` if deprecated cycle error otherwise set `result`.
464+
bool doSort(size_t relevantFlags, ref immutable(ModuleInfo)*[] result)
465465
{
466-
if (cycle)
467-
return;
468-
469466
clearFlags(relevant);
470467
clearFlags(ctorstart);
471468
clearFlags(ctordone);
@@ -495,33 +492,29 @@ struct ModuleGroup
495492
if (!bt(ctordone, idx))
496493
{
497494
if (!processMod(idx))
498-
{
499-
cycle = true;
500-
return;
501-
}
495+
return false;
502496
}
503497
}
504498

505499
if (ctoridx == 0)
506500
{
507501
// no ctors in the list.
508502
.free(ctors);
509-
result = null;
510-
return;
511503
}
512-
513-
ctors = cast(immutable(ModuleInfo)**).realloc(ctors, ctoridx * (void*).sizeof);
514-
if (ctors is null)
515-
assert(0);
516-
result = ctors[0 .. ctoridx];
517-
return;
504+
else
505+
{
506+
ctors = cast(immutable(ModuleInfo)**).realloc(ctors, ctoridx * (void*).sizeof);
507+
if (ctors is null)
508+
assert(0);
509+
result = ctors[0 .. ctoridx];
510+
}
511+
return true;
518512
}
519513

520-
// finally, do the sorting for both shared and tls ctors.
521-
bool cycle = false;
522-
doSort(MIctor | MIdtor, cycle, _ctors);
523-
doSort(MItlsctor | MItlsdtor, cycle, _tlsctors);
524-
if (cycle)
514+
// finally, do the sorting for both shared and tls ctors. If either returns false,
515+
// print the deprecation warning.
516+
if (!doSort(MIctor | MIdtor, _ctors) ||
517+
!doSort(MItlsctor | MItlsdtor, _tlsctors))
525518
{
526519
// print a warning
527520
import core.stdc.stdio : fprintf, stderr;

0 commit comments

Comments
 (0)