From 40a76c59ebf86a7b07ecb7fc8e97aa5b05b31ccb Mon Sep 17 00:00:00 2001 From: ruflin Date: Tue, 24 May 2016 14:21:30 +0200 Subject: [PATCH] Shorten copy --- filebeat/input/state.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/filebeat/input/state.go b/filebeat/input/state.go index 9b660a163a9..fc9b696b70e 100644 --- a/filebeat/input/state.go +++ b/filebeat/input/state.go @@ -106,17 +106,13 @@ func (s *States) Count() int { // Returns a copy of the file states func (s *States) GetStates() []FileState { - s.mutex.Lock() defer s.mutex.Unlock() - copy := make([]FileState, len(s.states)) - - for i := range s.states { - copy[i] = s.states[i] - } + newStates := make([]FileState, len(s.states)) + copy(newStates, s.states) - return copy + return newStates } // SetStates overwrites all internal states with the given states array