From 592259eb73cc7e0e1eba8b834f4c52222400526a Mon Sep 17 00:00:00 2001 From: AnilChinchawale Date: Mon, 12 Nov 2018 12:06:38 +0530 Subject: [PATCH] refactor RemoveItemFromArray --- common/types.go | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/common/types.go b/common/types.go index 9836e28191..2eea16ab83 100644 --- a/common/types.go +++ b/common/types.go @@ -33,7 +33,6 @@ const ( BlockSigners = "0x0000000000000000000000000000000000000089" MasternodeVotingSMC = "0x0000000000000000000000000000000000000088" RandomizeSMC = "0x0000000000000000000000000000000000000090" - FoudationAddr = "0x0000000000000000000000000000000000000068" ) var ( @@ -247,24 +246,18 @@ func (a UnprefixedAddress) MarshalText() ([]byte, error) { // Extract validators from byte array. func RemoveItemFromArray(array []Address, items []Address) []Address { - if items == nil { + if len(items) == 0 { return array } - i := 0; - for i < len(array) { - value := array[i] - remove := false - for _, item := range items { - if value == item { + + for _, item := range items { + for i := len(array) - 1; i >= 0; i-- { + if array[i] == item { array = append(array[:i], array[i+1:]...) - remove = true - break } } - if !remove { - i++ - } } + return array }