From dc0cbce6e1d75858ba00684b960158098cdd944a Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Sun, 6 Nov 2016 14:04:44 +0100 Subject: [PATCH] optimize pickString --- transport/internet/authenticators/http/config.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/transport/internet/authenticators/http/config.go b/transport/internet/authenticators/http/config.go index 953d89a4e..62a1a8c43 100644 --- a/transport/internet/authenticators/http/config.go +++ b/transport/internet/authenticators/http/config.go @@ -35,10 +35,14 @@ func (this *Status) GetReason() string { func pickString(arr []string) string { n := len(arr) - if n == 0 { + switch n { + case 0: return "" + case 1: + return arr[0] + default: + return arr[dice.Roll(n)] } - return arr[dice.Roll(n)] } func (this *RequestConfig) PickUri() string {