// newIfCond creates a new If condition.
510501
func newIfCond(a, op, b string) (ifCond, error) {
	i := ifCond{a: a, op: op, b: b}
	if strings.HasPrefix(op, "not_") {
		i.neg = true
		i.op = op[4:]
	}

	switch i.op {
	case isOp:
		// It checks for equality.
		i.f = i.isFunc
	case notOp:
		// It checks for inequality.
		i.f = i.notFunc
	case hasOp:
		// It checks if b is a substring of a.
		i.f = strings.Contains
	case startsWithOp:
		// It checks if b is a prefix of a.
		i.f = strings.HasPrefix
	case endsWithOp:
		// It checks if b is a suffix of a.
		i.f = strings.HasSuffix
	case matchOp:
		// It does regexp matching of a against pattern in b and returns if they match.
		var err error
		if i.rex, err = regexp.Compile(i.b); err != nil {
			return ifCond{}, fmt.Errorf("Invalid regular expression: '%s', %v", i.b, err)
		}
		i.f = i.matchFunc
	default:
		return ifCond{}, fmt.Errorf("Invalid operator %v", i.op)
	}

	return i, nil
}
644288
func (i Int32) If(fn func(int32)) {
	if i.Present() {
		fn(*i.value)
	}
}
920404
func NewIntValue(i int) Value {
	value := &Value{}
	value.StoreInt(i)
	return *value
}
207217
func NewFromConfig(config *factory.Config) *Scheduler {
	metrics.Register()
	return &Scheduler{
		config: config,
	}
}
1106401
func (*StdClock) NowNanoseconds() int64 {
	sec, nsec, _ := now()
	return sec*1e9 + int64(nsec)
}
367270
func NewBreaker(threshold int, backoff time.Duration) *Breaker {
	return &Breaker{
		threshold: threshold,
		backoff:   backoff,
	}
}
1036493
func NewDecbufUvarintAt(bs ByteSlice, off int, castagnoliTable *crc32.Table) Decbuf {
	// We never have to access this method at the far end of the byte slice. Thus just checking
	// against the MaxVarintLen32 is sufficient.
	if bs.Len() < off+binary.MaxVarintLen32 {
		return Decbuf{E: ErrInvalidSize}
	}
	b := bs.Range(off, off+binary.MaxVarintLen32)

	l, n := binary.Uvarint(b)
	if n <= 0 || n > binary.MaxVarintLen32 {
		return Decbuf{E: errors.Errorf("invalid uvarint %d", n)}
	}

	if bs.Len() < off+n+int(l)+4 {
		return Decbuf{E: ErrInvalidSize}
	}

	// Load bytes holding the contents plus a CRC32 checksum.
	b = bs.Range(off+n, off+n+int(l)+4)
	dec := Decbuf{B: b[:len(b)-4]}

	if dec.Crc32(castagnoliTable) != binary.BigEndian.Uint32(b[len(b)-4:]) {
		return Decbuf{E: ErrInvalidChecksum}
	}
	return dec
}
487315
func (c *Canceller) NewContext() (context.Context, context.CancelFunc) {
	return context.WithCancel(c.ctx)
}
203869
func NewDefaultStdDev() (indicator *StdDev, err error) {
	timePeriod := 10
	return NewStdDev(timePeriod, gotrade.UseClosePrice)
}
458659
func Newf(c codes.Code, format string, a ...interface{}) *Status {
	return New(c, fmt.Sprintf(format, a...))
}
264641
func NewCarbonInterval(start, end *Carbon) (*CarbonInterval, error) {
	if start.Gte(end) {
		return nil, errors.New("The end date must be greater than the start date.")
	}

	return &CarbonInterval{
		Start: start,
		End: end,
	}, nil
}
511078
func NewRangeFrom(from int) (*Range, error) {
	return (&rangeBuilder{}).from(from, nil).Range()
}
492845
func NewFixedInterval(delay time.Duration, etype events.Type, echan chan<- error) *FixedInterval {
	interval := new(FixedInterval)
	interval.Init(delay, etype, echan)
	return interval
}
653581
func NewDefaultMacd() (indicator *Macd, err error) {
	fastTimePeriod := 12
	slowTimePeriod := 26
	signalTimePeriod := 9
	return NewMacd(fastTimePeriod, slowTimePeriod, signalTimePeriod, gotrade.UseClosePrice)
}
1241376
func mulAdd(rate int8, in, mul, add Input, numOutputs int) Input {
	CheckRate(rate)
	return NewInput("MulAdd", rate, 0, numOutputs, in, mul, add)
}
996719
func NewExponentialBackoff(initialTimeout, maxTimeout time.Duration) *ExponentialBackoff {
	return &ExponentialBackoff{
		t: float64(int64(initialTimeout / time.Millisecond)),
		f: 2.0,
		m: float64(int64(maxTimeout / time.Millisecond)),
	}
}
1171159
func (f *TimeFuncs) Millisecond(n interface{}) gotime.Duration {
	return gotime.Millisecond * gotime.Duration(conv.ToInt64(n))
}