From 682decc64b896fa693f9c063e92cdfaba3104612 Mon Sep 17 00:00:00 2001 From: jess Date: Sat, 5 Mar 2022 03:36:52 +0900 Subject: [PATCH] fix: remove mutex in prefixdb --- prefixdb.go | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/prefixdb.go b/prefixdb.go index 0b2d2a1cf..f7172b48d 100644 --- a/prefixdb.go +++ b/prefixdb.go @@ -27,8 +27,8 @@ func (pdb *PrefixDB) Get(key []byte) ([]byte, error) { if len(key) == 0 { return nil, errKeyEmpty } - pdb.mtx.Lock() - defer pdb.mtx.Unlock() + //pdb.mtx.Lock() + //defer pdb.mtx.Unlock() pkey := pdb.prefixed(key) value, err := pdb.db.Get(pkey) @@ -43,8 +43,8 @@ func (pdb *PrefixDB) Has(key []byte) (bool, error) { if len(key) == 0 { return false, errKeyEmpty } - pdb.mtx.Lock() - defer pdb.mtx.Unlock() + //pdb.mtx.Lock() + //defer pdb.mtx.Unlock() ok, err := pdb.db.Has(pdb.prefixed(key)) if err != nil { @@ -62,8 +62,8 @@ func (pdb *PrefixDB) Set(key []byte, value []byte) error { if value == nil { return errValueNil } - pdb.mtx.Lock() - defer pdb.mtx.Unlock() + //pdb.mtx.Lock() + //defer pdb.mtx.Unlock() pkey := pdb.prefixed(key) if err := pdb.db.Set(pkey, value); err != nil { @@ -80,8 +80,8 @@ func (pdb *PrefixDB) SetSync(key []byte, value []byte) error { if value == nil { return errValueNil } - pdb.mtx.Lock() - defer pdb.mtx.Unlock() + //pdb.mtx.Lock() + //defer pdb.mtx.Unlock() return pdb.db.SetSync(pdb.prefixed(key), value) } @@ -91,8 +91,8 @@ func (pdb *PrefixDB) Delete(key []byte) error { if len(key) == 0 { return errKeyEmpty } - pdb.mtx.Lock() - defer pdb.mtx.Unlock() + //pdb.mtx.Lock() + //defer pdb.mtx.Unlock() return pdb.db.Delete(pdb.prefixed(key)) } @@ -102,8 +102,8 @@ func (pdb *PrefixDB) DeleteSync(key []byte) error { if len(key) == 0 { return errKeyEmpty } - pdb.mtx.Lock() - defer pdb.mtx.Unlock() + //pdb.mtx.Lock() + //defer pdb.mtx.Unlock() return pdb.db.DeleteSync(pdb.prefixed(key)) } @@ -113,8 +113,8 @@ func (pdb *PrefixDB) Iterator(start, end []byte) (Iterator, error) { if (start != nil && len(start) == 0) || (end != nil && len(end) == 0) { return nil, errKeyEmpty } - pdb.mtx.Lock() - defer pdb.mtx.Unlock() + //pdb.mtx.Lock() + //defer pdb.mtx.Unlock() var pstart, pend []byte pstart = append(cp(pdb.prefix), start...) @@ -136,8 +136,8 @@ func (pdb *PrefixDB) ReverseIterator(start, end []byte) (Iterator, error) { if (start != nil && len(start) == 0) || (end != nil && len(end) == 0) { return nil, errKeyEmpty } - pdb.mtx.Lock() - defer pdb.mtx.Unlock() + //pdb.mtx.Lock() + //defer pdb.mtx.Unlock() var pstart, pend []byte pstart = append(cp(pdb.prefix), start...) @@ -156,8 +156,8 @@ func (pdb *PrefixDB) ReverseIterator(start, end []byte) (Iterator, error) { // NewBatch implements DB. func (pdb *PrefixDB) NewBatch() Batch { - pdb.mtx.Lock() - defer pdb.mtx.Unlock() + //pdb.mtx.Lock() + //defer pdb.mtx.Unlock() return newPrefixBatch(pdb.prefix, pdb.db.NewBatch()) }