// increaseDelay returns an delay, increased from an old delay with a given
// factor, limited to given min & max.
490246
func increaseDelay(oldDelay time.Duration, factor float64, min, max time.Duration) time.Duration {
	delay := time.Duration(float64(oldDelay) * factor)
	if delay < min {
		delay = min
	}
	if delay > max {
		delay = max
	}
	return delay
}
657752
func newLFunctionL(proto *FunctionProto, env *LTable, nupvalue int) *LFunction {
	return &LFunction{
		IsG: false,
		Env: env,

		Proto:     proto,
		GFunction: nil,
		Upvalues:  make([]*Upvalue, nupvalue),
	}
}
1023146
func (t *SleepClock) Advance(d time.Duration) {
	t.mu.Lock()
	defer t.mu.Unlock()
	t.currentTime = t.currentTime.Add(d)
	for k, v := range t.waiters {
		if k.Before(t.currentTime) {
			for _, c := range v {
				c <- t.currentTime
			}
			delete(t.waiters, k)
		}
	}

}
1242903
func (t *Tube) PeekDelayed() (id uint64, body []byte, err error) {
	r, err := t.Conn.cmd(t, nil, nil, "peek-delayed")
	if err != nil {
		return 0, nil, err
	}
	body, err = t.Conn.readResp(r, true, "FOUND %d", &id)
	if err != nil {
		return 0, nil, err
	}
	return id, body, nil
}
675723
func (a AcceptSlice) Less(i, j int) bool {
	// Higher qvalues come first.
	if a[i].Q > a[j].Q {
		return true
	} else if a[i].Q < a[j].Q {
		return false
	}

	// Specific types come before wildcard types.
	if a[i].Type != "*" && a[j].Type == "*" {
		return true
	} else if a[i].Type == "*" && a[j].Type != "*" {
		return false
	}

	// Specific subtypes come before wildcard subtypes.
	if a[i].Subtype != "*" && a[j].Subtype == "*" {
		return true
	} else if a[i].Subtype == "*" && a[j].Subtype != "*" {
		return false
	}

	// A lot of extensions comes before not a lot of extensions.
	if len(a[i].Extensions) > len(a[j].Extensions) {
		return true
	}

	return false
}
240784
func Max(Len int, Less func(i, j int) bool) int {
	mx := 0
	for i := 1; i < Len; i++ {
		if Less(mx, i) {
			mx = i
		}
	}
	return mx
}
987338
func (s *DynamicBanScore) Increase(persistent, transient uint32) uint32 {
	s.mtx.Lock()
	r := s.increase(persistent, transient, time.Now())
	s.mtx.Unlock()
	return r
}
726479
func (pq *ScoreHeap) Push(x interface{}) {
	item := x.(HeapItem)
	if len(pq.items) < pq.capacity {
		pq.items = append(pq.items, item)
	} else {
		// Pop the lowest scoring element if this item's Score is
		// greater than the min Score so far
		minIndex := 0
		min := pq.items[minIndex]
		if item.Score() > min.Score() {
			// Replace min and heapify
			pq.items[minIndex] = item
			heap.Fix(pq, minIndex)
		}
	}
}
130052
func (q *rateLimitingType) AddRateLimited(item interface{}) {
	q.DelayingInterface.AddAfter(item, q.rateLimiter.When(item))
}
887106
func (l *CList) PushBack(v interface{}) *CElement {
	l.mtx.Lock()

	// Construct a new element
	e := &CElement{
		prev:       nil,
		prevWg:     waitGroup1(),
		prevWaitCh: make(chan struct{}),
		next:       nil,
		nextWg:     waitGroup1(),
		nextWaitCh: make(chan struct{}),
		removed:    false,
		Value:      v,
	}

	// Release waiters on FrontWait/BackWait maybe
	if l.len == 0 {
		l.wg.Done()
		close(l.waitCh)
	}
	if l.len >= l.maxLen {
		panic(fmt.Sprintf("clist: maximum length list reached %d", l.maxLen))
	}
	l.len++

	// Modify the tail
	if l.tail == nil {
		l.head = e
		l.tail = e
	} else {
		e.SetPrev(l.tail) // We must init e first.
		l.tail.SetNext(e) // This will make e accessible.
		l.tail = e        // Update the list.
	}
	l.mtx.Unlock()
	return e
}
241830
func defaultResourceFailureDelay(requeue int) (time.Duration, bool) {
	if requeue > 5 {
		return maxResourceInterval, true
	}
	t := time.Duration(math.Pow(2.0, float64(requeue)) * float64(time.Second))
	if t > maxResourceInterval {
		t = maxResourceInterval
	}
	return t, true
}
798190
func (options PoolOptions) WithMaxIdle(maxIdle int) PoolOptions {
	options.MaxIdle = maxIdle
	return options
}
614711
func (tokenizer *Tokenizer) AdvanceTriple() error {
	for tokenizer.CanRead() {
		if tokenizer.scanner.Char() == '.' {
			break
		}
		if tokenizer.isWhiteSpaceChar() {
			tokenizer.scanner.Advance()
			continue
		}
		return tokenizer.Error("Triple did not end with a period.")
	}
	tokenizer.scanner.Advance()
	return nil
}
939106
func (t *RandomInterval) GetDelay() time.Duration {
	t.delay = time.Duration(rand.Int63n(t.maxDelay-t.minDelay) + t.minDelay)
	return t.delay
}
101601
func (c *UpdateFailHTLC) MaxPayloadLength(uint32) uint32 {
	var length uint32

	// Length of the ChanID
	length += 32

	// Length of the ID
	length += 8

	// Length of the length opaque reason
	length += 2

	// Length of the Reason
	length += 292

	return length
}
622788
func DiffArray(configArray, liveArray []*unstructured.Unstructured, normalizer Normalizer) (*DiffResultList, error) {
	numItems := len(configArray)
	if len(liveArray) != numItems {
		return nil, fmt.Errorf("left and right arrays have mismatched lengths")
	}

	diffResultList := DiffResultList{
		Diffs: make([]DiffResult, numItems),
	}
	for i := 0; i < numItems; i++ {
		config := configArray[i]
		live := liveArray[i]
		diffRes := Diff(config, live, normalizer)
		diffResultList.Diffs[i] = *diffRes
		if diffRes.Modified {
			diffResultList.Modified = true
		}
	}
	return &diffResultList, nil
}
833571
func (q *MoreLikeThisQuery) Boost(boost float64) *MoreLikeThisQuery {
	q.boost = &boost
	return q
}