Skip to content

Commit

Permalink
Revert "Implement slowEqual speed enhancement from ssbc#128"
Browse files Browse the repository at this point in the history
This reverts commit 873940d.
  • Loading branch information
Barbarrosa committed Apr 11, 2021
1 parent c288c0f commit a8961d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
10 changes: 6 additions & 4 deletions operators.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ function toBufferOrFalsy(value) {
function seekFromDesc(desc) {
const keys = desc.split('.')
// The 2nd arg `start` is to support plucks too
const compiledSeek = bipf.createSeekPath(keys)
return (buffer, start = 0) => {
const p = compiledSeek(buffer, start)
if (!~p) return void 0
else return p
var p = start
for (let key of keys) {
p = bipf.seekKey(buffer, p, Buffer.from(key))
if (!~p) return void 0
}
return p
}
}

Expand Down
10 changes: 5 additions & 5 deletions test/operators.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ prepareAndRunTest('operators API supports slowEqual', dir, (t, db, raf) => {
t.equal(queryTree.data.indexType, 'value_content_type')
t.notOk(queryTree.data.indexAll)
t.deepEqual(queryTree.data.value, Buffer.from('post'))
t.true(queryTree.data.seek.toString().includes('compiledSeek'))
t.true(queryTree.data.seek.toString().includes('bipf.seekKey'))

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

t.end()
})
Expand Down Expand Up @@ -253,7 +253,7 @@ prepareAndRunTest('slowEqual with prefix', dir, (t, db, raf) => {

t.equal(queryTree.data.indexType, 'value_content_type')
t.deepEqual(queryTree.data.value, Buffer.from('post'))
t.true(queryTree.data.seek.toString().includes('compiledSeek'))
t.true(queryTree.data.seek.toString().includes('bipf.seekKey'))
t.equal(queryTree.data.prefix, 32)

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

t.equal(queryTree.data[1].data[1].type, 'EQUAL')
t.equal(queryTree.data[1].data[1].data.indexType, 'value_author')
t.deepEqual(queryTree.data[1].data[1].data.value, Buffer.from(bob.id))
t.true(
queryTree.data[1].data[1].data.seek.toString().includes('compiledSeek')
queryTree.data[1].data[1].data.seek.toString().includes('bipf.seekKey')
)

t.end()
Expand Down

0 comments on commit a8961d2

Please sign in to comment.