Skip to content

Commit b7602f0

Browse files
committed
minor cleanup
1 parent 40c9e67 commit b7602f0

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ This repo contains several simple balanced binary search tree JavaScript impleme
77
- `bsarray.js`: pseudo-BBST internally stored as a simple JS array
88
- `llrb.js`: Sedgewick's [Left-Leaning Red-Black Tree](http://algs4.cs.princeton.edu/33balanced/)
99

10-
Benchmarks contain comparisons with [functional-red-black-tree](https://github.com/mikolalysenko/functional-red-black-tree) (incredibly, insanely fast, still not sure why) and [js_bintrees](https://github.com/vadimg/js_bintrees).
10+
Benchmarks contain comparisons with [functional-red-black-tree](https://github.com/mikolalysenko/functional-red-black-tree) and [js_bintrees](https://github.com/vadimg/js_bintrees).
11+
12+
The goal is to create the fastest and at the same time the simplest JS balanced binary search tree library.
1113

1214
Example usage of trees:
1315

llrb.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12

23
module.exports = llrb;
34

@@ -19,12 +20,12 @@ function Node(key, value, red) {
1920

2021
LLRBTree.prototype = {
2122
find: function (key) {
22-
var x = this.root,
23-
compare = this.compare;
24-
while (x) {
25-
var c = compare(key, x.key);
26-
if (c === 0) return x;
27-
x = c < 0 ? x.left : x.right;
23+
var n = this.root,
24+
cmp = this.compare;
25+
while (n) {
26+
var c = cmp(key, n.key);
27+
if (c === 0) return n;
28+
n = c < 0 ? n.left : n.right;
2829
}
2930
return null;
3031
},

0 commit comments

Comments
 (0)