From 544ee489a4464c615cee0c0bcee80fbfceab6809 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sun, 22 Apr 2018 01:05:51 +0200 Subject: [PATCH] [context] min cleanup --- src/git.xdrm.io/schastsp/context/context.go | 28 ++++++++++----------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/git.xdrm.io/schastsp/context/context.go b/src/git.xdrm.io/schastsp/context/context.go index a6fab75..221bb9f 100644 --- a/src/git.xdrm.io/schastsp/context/context.go +++ b/src/git.xdrm.io/schastsp/context/context.go @@ -30,47 +30,45 @@ type T struct { * @return outName outDesc * ---------------------------------------------------------*/ - func Create(win float64, optional... uint16) (*T, error) { - var instance = new(T); + var inst = new(T); /* (1) Window size error */ if win < 0 { return nil, errors.New("Window size must be positive and is negative") } - instance.win = win; + inst.win = win; /* (2) Default values */ - instance.min = DefaultMin - instance.thr = DefaultThr - instance.max = DefaultMax + inst.min = DefaultMin + inst.thr = DefaultThr + inst.max = DefaultMax /* (3) Optional 'min' */ if len(optional) > 0 { - if optional[0] < 0x0f { return nil, errors.New("Minimum depth must be greater than 0x0f (decimal 15) for consistency issues") } - - instance.min = optional[0]; + if optional[0] < 0x0f { + return nil, errors.New("Minimum depth must be greater than 0x0f (decimal 15) for consistency issues") + } + inst.min = optional[0]; } /* (4) Optional 'thr' */ if len(optional) > 1 { - instance.thr = optional[1]; + inst.thr = optional[1]; } - /* (5) Optional 'max' */ if len(optional) > 2 { - if optional[2] <= instance.min+instance.thr { + if optional[2] <= inst.min+inst.thr { return nil, errors.New("Minimum depth must be greater than 0x0f (decimal 15) for consistency issues") } - - instance.max = optional[2]; + inst.max = optional[2]; } - return instance, nil + return inst, nil } /* (4) Getters */