Skip to content

Commit fbb0053

Browse files
authored
Merge pull request #49 from Megra/remove-dead-cycles
Remove dead cycles
2 parents 0386e50 + ea662c4 commit fbb0053

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

FBRetainCycleDetector/Detector/FBRetainCycleDetector.mm

+15
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,21 @@ - (void)addCandidate:(id)candidate
6969
[_candidates removeAllObjects];
7070
[_objectSet removeAllObjects];
7171

72+
// Filter cycles that have been broken down since we found them.
73+
// These are false-positive that were picked-up and are transient cycles.
74+
NSMutableSet<NSArray<FBObjectiveCGraphElement *> *> *brokenCycles = [NSMutableSet set];
75+
for (NSArray<FBObjectiveCGraphElement *> *itemCycle in allRetainCycles) {
76+
for (FBObjectiveCGraphElement *element in itemCycle) {
77+
if (element.object == nil) {
78+
// At least one element of the cycle has been removed, thus breaking
79+
// the cycle.
80+
[brokenCycles addObject:itemCycle];
81+
break;
82+
}
83+
}
84+
}
85+
[allRetainCycles minusSet:brokenCycles];
86+
7287
return allRetainCycles;
7388
}
7489

FBRetainCycleDetector/Graph/FBObjectiveCBlock.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ - (NSString *)classNameOrNull
7272
{
7373
NSString *className = NSStringFromClass([self objectClass]);
7474
if (!className) {
75-
className = @"Null";
75+
className = @"(null)";
7676
}
7777

7878
if (!self.configuration.shouldIncludeBlockAddress) {

FBRetainCycleDetector/Graph/FBObjectiveCGraphElement.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ - (NSString *)classNameOrNull
116116
{
117117
NSString *className = NSStringFromClass([self objectClass]);
118118
if (!className) {
119-
className = @"Null";
119+
className = @"(null)";
120120
}
121121

122122
return className;

0 commit comments

Comments
 (0)