From ef63abdf7f9bc1a0411e772c9734317fb92714a7 Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Tue, 6 Jun 2017 09:49:35 -0700 Subject: [PATCH] mvcc: don't use pointer for storeTxnRead in storeTxnWrite Saves an allocation when creating a storeTxnWrite. --- mvcc/kvstore_bench_test.go | 1 + mvcc/kvstore_txn.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mvcc/kvstore_bench_test.go b/mvcc/kvstore_bench_test.go index 547a5d91e..b0db47f11 100644 --- a/mvcc/kvstore_bench_test.go +++ b/mvcc/kvstore_bench_test.go @@ -95,6 +95,7 @@ func BenchmarkStoreTxnPut(b *testing.B) { vals := createBytesSlice(bytesN, b.N) b.ResetTimer() + b.ReportAllocs() for i := 0; i < b.N; i++ { txn := s.Write() txn.Put(keys[i], vals[i], lease.NoLease) diff --git a/mvcc/kvstore_txn.go b/mvcc/kvstore_txn.go index 1e6147551..ae8d37238 100644 --- a/mvcc/kvstore_txn.go +++ b/mvcc/kvstore_txn.go @@ -51,7 +51,7 @@ func (tr *storeTxnRead) End() { } type storeTxnWrite struct { - *storeTxnRead + storeTxnRead tx backend.BatchTx // beginRev is the revision where the txn begins; it will write to the next revision. beginRev int64 @@ -63,7 +63,7 @@ func (s *store) Write() TxnWrite { tx := s.b.BatchTx() tx.Lock() tw := &storeTxnWrite{ - storeTxnRead: &storeTxnRead{s, tx, 0, 0}, + storeTxnRead: storeTxnRead{s, tx, 0, 0}, tx: tx, beginRev: s.currentRev, changes: make([]mvccpb.KeyValue, 0, 4),