Skip to content

Commit a8961d2

Browse files
committed
Revert "Implement slowEqual speed enhancement from ssbc#128"
This reverts commit 873940d.
1 parent c288c0f commit a8961d2

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

operators.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ function toBufferOrFalsy(value) {
3434
function seekFromDesc(desc) {
3535
const keys = desc.split('.')
3636
// The 2nd arg `start` is to support plucks too
37-
const compiledSeek = bipf.createSeekPath(keys)
3837
return (buffer, start = 0) => {
39-
const p = compiledSeek(buffer, start)
40-
if (!~p) return void 0
41-
else return p
38+
var p = start
39+
for (let key of keys) {
40+
p = bipf.seekKey(buffer, p, Buffer.from(key))
41+
if (!~p) return void 0
42+
}
43+
return p
4244
}
4345
}
4446

test/operators.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ prepareAndRunTest('operators API supports slowEqual', dir, (t, db, raf) => {
8989
t.equal(queryTree.data.indexType, 'value_content_type')
9090
t.notOk(queryTree.data.indexAll)
9191
t.deepEqual(queryTree.data.value, Buffer.from('post'))
92-
t.true(queryTree.data.seek.toString().includes('compiledSeek'))
92+
t.true(queryTree.data.seek.toString().includes('bipf.seekKey'))
9393

9494
t.equal(typeof queryTree.meta, 'object', 'queryTree contains meta')
9595
t.equal(
@@ -186,7 +186,7 @@ prepareAndRunTest('slowEqual 3 args', dir, (t, db, raf) => {
186186
t.equal(queryTree.data.indexType, 'value_content_type')
187187
t.equal(queryTree.data.indexAll, true)
188188
t.deepEqual(queryTree.data.value, Buffer.from('post'))
189-
t.true(queryTree.data.seek.toString().includes('compiledSeek'))
189+
t.true(queryTree.data.seek.toString().includes('bipf.seekKey'))
190190

191191
t.end()
192192
})
@@ -253,7 +253,7 @@ prepareAndRunTest('slowEqual with prefix', dir, (t, db, raf) => {
253253

254254
t.equal(queryTree.data.indexType, 'value_content_type')
255255
t.deepEqual(queryTree.data.value, Buffer.from('post'))
256-
t.true(queryTree.data.seek.toString().includes('compiledSeek'))
256+
t.true(queryTree.data.seek.toString().includes('bipf.seekKey'))
257257
t.equal(queryTree.data.prefix, 32)
258258

259259
t.end()
@@ -300,14 +300,14 @@ prepareAndRunTest('operators API supports or()', dir, (t, db, raf) => {
300300
t.deepEqual(queryTree.data[1].data[0].data.indexType, 'value_author')
301301
t.deepEqual(queryTree.data[1].data[0].data.value, Buffer.from(alice.id))
302302
t.true(
303-
queryTree.data[1].data[0].data.seek.toString().includes('compiledSeek')
303+
queryTree.data[1].data[0].data.seek.toString().includes('bipf.seekKey')
304304
)
305305

306306
t.equal(queryTree.data[1].data[1].type, 'EQUAL')
307307
t.equal(queryTree.data[1].data[1].data.indexType, 'value_author')
308308
t.deepEqual(queryTree.data[1].data[1].data.value, Buffer.from(bob.id))
309309
t.true(
310-
queryTree.data[1].data[1].data.seek.toString().includes('compiledSeek')
310+
queryTree.data[1].data[1].data.seek.toString().includes('bipf.seekKey')
311311
)
312312

313313
t.end()

0 commit comments

Comments
 (0)