mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
storage: make putm/delm a set with empty value
This cleans the code, and reduces the allocation space.
This commit is contained in:
parent
6dbfc21846
commit
c8e622f517
@ -304,26 +304,26 @@ func (s *watchableStore) notify(rev int64, ev storagepb.Event) {
|
|||||||
|
|
||||||
type ongoingTx struct {
|
type ongoingTx struct {
|
||||||
// keys put/deleted in the ongoing txn
|
// keys put/deleted in the ongoing txn
|
||||||
putm map[string]bool
|
putm map[string]struct{}
|
||||||
delm map[string]bool
|
delm map[string]struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newOngoingTx() *ongoingTx {
|
func newOngoingTx() *ongoingTx {
|
||||||
return &ongoingTx{
|
return &ongoingTx{
|
||||||
putm: make(map[string]bool),
|
putm: make(map[string]struct{}),
|
||||||
delm: make(map[string]bool),
|
delm: make(map[string]struct{}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tx *ongoingTx) put(k string) {
|
func (tx *ongoingTx) put(k string) {
|
||||||
tx.putm[k] = true
|
tx.putm[k] = struct{}{}
|
||||||
if _, ok := tx.delm[k]; ok {
|
if _, ok := tx.delm[k]; ok {
|
||||||
delete(tx.delm, k)
|
delete(tx.delm, k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tx *ongoingTx) del(k string) {
|
func (tx *ongoingTx) del(k string) {
|
||||||
tx.delm[k] = true
|
tx.delm[k] = struct{}{}
|
||||||
if _, ok := tx.putm[k]; ok {
|
if _, ok := tx.putm[k]; ok {
|
||||||
delete(tx.putm, k)
|
delete(tx.putm, k)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user