Skip to content

Commit

Permalink
Pass by reference instead of value to reduce bytes copied
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Masley committed Apr 28, 2017
1 parent c90d3fe commit dd1c8cc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions p2p/controller.go
Expand Up @@ -396,9 +396,9 @@ func (c *Controller) route() {
message := <-connection.ReceiveChannel
switch message.(type) {
case ConnectionCommand:
c.handleConnectionCommand(message.(ConnectionCommand), *connection)
c.handleConnectionCommand(message.(ConnectionCommand), connection)
case ConnectionParcel:
c.handleParcelReceive(message, peerHash, *connection)
c.handleParcelReceive(message, peerHash, connection)
default:
logfatal("ctrlr", "route() unknown message?: %+v ", message)
}
Expand Down Expand Up @@ -491,7 +491,7 @@ func (c *Controller) doDirectedSend(parcel Parcel) {
}

// handleParcelReceive takes a parcel from the network and annotates it for the application then routes it.
func (c *Controller) handleParcelReceive(message interface{}, peerHash string, connection Connection) {
func (c *Controller) handleParcelReceive(message interface{}, peerHash string, connection *Connection) {
TotalMessagesRecieved++
parameters := message.(ConnectionParcel)
parcel := parameters.Parcel
Expand Down Expand Up @@ -521,7 +521,7 @@ func (c *Controller) handleParcelReceive(message interface{}, peerHash string, c

}

func (c *Controller) handleConnectionCommand(command ConnectionCommand, connection Connection) {
func (c *Controller) handleConnectionCommand(command ConnectionCommand, connection *Connection) {
switch command.Command {
case ConnectionUpdateMetrics:
c.connectionMetrics[connection.peer.Hash] = command.Metrics
Expand Down

0 comments on commit dd1c8cc

Please sign in to comment.