Skip to content

Commit f10a183

Browse files
🎨 style(blossom): Reduce scope of variables and use booleans where it makes sense.
1 parent c9ce5cc commit f10a183

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/core/blossom/blossom.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -537,12 +537,11 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
537537
// Bubble up through the blossom tree from vertex v to an immediate
538538
// sub-blossom of b.
539539
let j;
540-
let t;
541540
let jstep;
542541
let endptrick;
543542
let stop;
544543
let p;
545-
t = v;
544+
let t = v;
546545
while (blossomparent[t] !== b) t = blossomparent[t];
547546
// Recursively deal with the first sub-blossom.
548547
if (t >= nvertex) augmentBlossom(t, v);
@@ -652,9 +651,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
652651

653652
let b;
654653
let d;
655-
let t;
656654
let v;
657-
let augmented;
658655
let kslack;
659656
let base;
660657
let deltatype;
@@ -663,7 +660,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
663660
let deltablossom;
664661

665662
// Main loop: continue until no further improvement is possible.
666-
for (t = 0; t < nvertex; ++t) {
663+
for (let t = 0; t < nvertex; ++t) {
667664
// Each iteration of this loop is a "stage".
668665
// A stage finds an augmenting path and uses that to improve
669666
// the matching.
@@ -689,7 +686,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
689686
}
690687

691688
// Loop until we succeed in augmenting the matching.
692-
augmented = 0;
689+
let augmented = false;
693690
// eslint-disable-next-line no-constant-condition
694691
while (true) {
695692
// Each iteration of this loop is a "substage".
@@ -746,7 +743,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
746743
// Found an augmenting path; augment the
747744
// matching and end this stage.
748745
augmentMatching(k);
749-
augmented = 1;
746+
augmented = true;
750747
break;
751748
}
752749
} else if (label[w] === 0) {

0 commit comments

Comments
 (0)