Skip to content
This repository has been archived by the owner on Mar 9, 2019. It is now read-only.

Commit

Permalink
Merge pull request #119 from benbjohnson/tx-rename
Browse files Browse the repository at this point in the history
Rename internal local Tx variables.
  • Loading branch information
benbjohnson committed Apr 4, 2014
2 parents af1551e + 12204df commit 3f7dbff
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 152 deletions.
4 changes: 2 additions & 2 deletions cursor.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func (c *Cursor) keyValue() ([]byte, []byte) {
}

// node returns the node that the cursor is currently positioned on.
func (c *Cursor) node(t *Tx) *node {
func (c *Cursor) node(tx *Tx) *node {
_assert(len(c.stack) > 0, "accessing a node with a zero-length cursor stack")

// If the top of the stack is a leaf node then just return it.
Expand All @@ -270,7 +270,7 @@ func (c *Cursor) node(t *Tx) *node {
// Start from root and traverse down the hierarchy.
var n = c.stack[0].node
if n == nil {
n = t.node(c.stack[0].page.id, nil)
n = tx.node(c.stack[0].page.id, nil)
}
for _, ref := range c.stack[:len(c.stack)-1] {
_assert(!n.isLeaf, "expected branch node")
Expand Down
8 changes: 4 additions & 4 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,23 +361,23 @@ func (db *DB) beginRWTx() (*Tx, error) {
}

// removeTx removes a transaction from the database.
func (db *DB) removeTx(t *Tx) {
func (db *DB) removeTx(tx *Tx) {
db.metalock.Lock()
defer db.metalock.Unlock()

// Release the read lock on the mmap.
db.mmaplock.RUnlock()

// Remove the transaction.
for i, tx := range db.txs {
if tx == t {
for i, t := range db.txs {
if t == tx {
db.txs = append(db.txs[:i], db.txs[i+1:]...)
break
}
}

// Merge statistics.
db.stats.TxStats.add(&t.stats)
db.stats.TxStats.add(&tx.stats)
}

// Update executes a function within the context of a read-write managed transaction.
Expand Down
4 changes: 2 additions & 2 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ func ExampleDB_View() {
})

// Access data from within a read-only transactional block.
db.View(func(t *Tx) error {
v := t.Bucket("people").Get([]byte("john"))
db.View(func(tx *Tx) error {
v := tx.Bucket("people").Get([]byte("john"))
fmt.Printf("John's last name is %s.\n", string(v))
return nil
})
Expand Down
Loading

0 comments on commit 3f7dbff

Please sign in to comment.