diff options
author | EuAndreh <eu@euandre.org> | 2025-02-10 13:21:39 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2025-02-10 13:21:39 -0300 |
commit | 8b92b37d9c389c78b81c2670c37a6a550afafc76 (patch) | |
tree | 8992bdd49aa2766848661ba5612719eef3911335 | |
parent | src/dedo.go: Simple rename Cursor -> cursorT (diff) | |
download | dedo-8b92b37d9c389c78b81c2670c37a6a550afafc76.tar.gz dedo-8b92b37d9c389c78b81c2670c37a6a550afafc76.tar.xz |
src/dedo.go: Remove duplicate code of bucketT.NextID()
-rw-r--r-- | src/dedo.go | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/dedo.go b/src/dedo.go index e711000..f3916c9 100644 --- a/src/dedo.go +++ b/src/dedo.go @@ -836,21 +836,11 @@ func bytesLE(num uint64) []byte { } func (b *bucketT) NextID() []byte { - if b.tx.db == nil { - panic(ErrTxClosed) - } else if !b.tx.writable { - panic(ErrTxNotWritable) - } - - // Materialize the root node if it hasn't been already so that the - // bucket will be saved during commit. - if b.rootNode == nil { - _ = b.node(b.ref.root, nil) + id, err := b.NextSequence() + if err != nil { + panic(err) } - - // Increment and return the sequence. - b.ref.sequence++ - return bytesLE(b.ref.sequence) + return bytesLE(id) } /// bucketT.NextSequence() returns an autoincrementing integer for the bucket. |