From 1ca74b404a0cca1ad574edec47785e72c170a9ab Mon Sep 17 00:00:00 2001 From: siddontang Date: Wed, 19 Nov 2014 09:30:28 +0800 Subject: [PATCH] rpl optimize --- store/writebatch.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/store/writebatch.go b/store/writebatch.go index 3e0d138..a69dbd8 100644 --- a/store/writebatch.go +++ b/store/writebatch.go @@ -14,6 +14,8 @@ type WriteBatch struct { putNum int64 deleteNum int64 db *DB + + data *BatchData } func (wb *WriteBatch) Close() { @@ -60,13 +62,12 @@ func (wb *WriteBatch) Rollback() error { // the data will be undefined after commit or rollback func (wb *WriteBatch) BatchData() *BatchData { data := wb.wb.Data() - d, err := NewBatchData(data) - if err != nil { - //can not enter this - panic(err) + if wb.data == nil { + wb.data = new(BatchData) } - return d + wb.data.Load(data) + return wb.data } func (wb *WriteBatch) Data() []byte {