From a8961d2387c2e372beb5e4664e6bbddd29c88a9d Mon Sep 17 00:00:00 2001 From: Timothy Bradley Date: Sun, 11 Apr 2021 13:23:56 -0700 Subject: [PATCH] Revert "Implement slowEqual speed enhancement from #128" This reverts commit 873940d530ae24da3c8da1c67bd7c0b8788cf569. --- operators.js | 10 ++++++---- test/operators.js | 10 +++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/operators.js b/operators.js index 07b73ad..feb6370 100644 --- a/operators.js +++ b/operators.js @@ -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 } } diff --git a/test/operators.js b/test/operators.js index a31000b..619e338 100644 --- a/test/operators.js +++ b/test/operators.js @@ -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( @@ -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() }) @@ -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() @@ -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()