From ebce5d07ac20565900cd052c9ca33b286de6fa28 Mon Sep 17 00:00:00 2001 From: "Lars K.W. Gohlke" Date: Tue, 24 May 2016 21:57:56 +0000 Subject: [PATCH] lib/connections: Shorten connection limiting lines GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3177 --- lib/connections/service.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/connections/service.go b/lib/connections/service.go index 5c80abbb..bfbc2b9c 100644 --- a/lib/connections/service.go +++ b/lib/connections/service.go @@ -90,11 +90,13 @@ func NewService(cfg *config.Wrapper, myID protocol.DeviceID, mdl Model, tlsCfg * // The rate variables are in KiB/s in the UI (despite the camel casing // of the name). We multiply by 1024 here to get B/s. - if service.cfg.Options().MaxSendKbps > 0 { - service.writeRateLimit = ratelimit.NewBucketWithRate(float64(1024*service.cfg.Options().MaxSendKbps), int64(5*1024*service.cfg.Options().MaxSendKbps)) + options := service.cfg.Options() + if options.MaxSendKbps > 0 { + service.writeRateLimit = ratelimit.NewBucketWithRate(float64(1024*options.MaxSendKbps), int64(5*1024*options.MaxSendKbps)) } - if service.cfg.Options().MaxRecvKbps > 0 { - service.readRateLimit = ratelimit.NewBucketWithRate(float64(1024*service.cfg.Options().MaxRecvKbps), int64(5*1024*service.cfg.Options().MaxRecvKbps)) + + if options.MaxRecvKbps > 0 { + service.readRateLimit = ratelimit.NewBucketWithRate(float64(1024*options.MaxRecvKbps), int64(5*1024*options.MaxRecvKbps)) } // There are several moving parts here; one routine per listening address