From 0e857e4467dc36ef8c24412bca1ee7537bded238 Mon Sep 17 00:00:00 2001 From: Stefano Gabryel Date: Sat, 20 Apr 2019 16:51:14 +0200 Subject: [PATCH] Minor improvements to prevent unecessaries allocations --- core/core.go | 4 ++-- modules/net_recon/net_show.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/core.go b/core/core.go index 3761a6c7..e265af6b 100644 --- a/core/core.go +++ b/core/core.go @@ -8,8 +8,8 @@ import ( ) func UniqueInts(a []int, sorted bool) []int { - tmp := make(map[int]bool) - uniq := make([]int, 0) + tmp := make(map[int]bool, len(a)) + uniq := make([]int, 0, len(a)) for _, n := range a { tmp[n] = true diff --git a/modules/net_recon/net_show.go b/modules/net_recon/net_show.go index 01c604a2..da4bcd34 100644 --- a/modules/net_recon/net_show.go +++ b/modules/net_recon/net_show.go @@ -15,7 +15,7 @@ import ( "github.com/evilsocket/islazy/tui" ) -var ( +const ( AliveTimeInterval = time.Duration(10) * time.Second PresentTimeInterval = time.Duration(1) * time.Minute JustJoinedTimeInterval = time.Duration(10) * time.Second @@ -109,7 +109,7 @@ func (mod *Discovery) getRow(e *network.Endpoint, withMeta bool) [][]string { }) sort.Strings(metas) - rows := [][]string{} + rows := make([][]string, 0, len(metas)) for i, m := range metas { if i == 0 { rows = append(rows, append(row, m))