Skip to content

Commit

Permalink
Rewrite this logic to make it clearer.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay authored and egonw committed Feb 20, 2022
1 parent d44f11a commit e07f7b6
Showing 1 changed file with 6 additions and 4 deletions.
Expand Up @@ -523,24 +523,26 @@ private int[] growAtoms(int[] atoms) {
private void considerNewFP(FP newFP) {
//wr("CONSIDER:"+newFP.iteration+",hash="+newFP.hashCode); //foo
int hit = -1;
FP fp = null;
FP hitFp = null;
for (int n = 0; n < fplist.size(); n++) {
fp = fplist.get(n);
FP fp = fplist.get(n);
boolean equal = fp.atoms.length == newFP.atoms.length;
for (int i = fp.atoms.length - 1; equal && i >= 0; i--)
if (fp.atoms[i] != newFP.atoms[i]) equal = false;
if (equal) {
hit = n;
hitFp = fp;
break;
}
}
if (hit < 0) {
if (hitFp == null) {
fplist.add(newFP);
return;
}

// if the preexisting fingerprint is from an earlier iteration, or has a lower hashcode, discard
if (fp.iteration < newFP.iteration || fp.hashCode < newFP.hashCode) return;
if (hitFp.iteration < newFP.iteration || hitFp.hashCode < newFP.hashCode)
return;
fplist.set(hit, newFP);
}

Expand Down

0 comments on commit e07f7b6

Please sign in to comment.