// NewUlimit creates a Ulimit based on the specified parts.
179492
func NewUlimit(name string, soft int64, hard int64) Ulimit {
	return Ulimit{
		Name: name,
		ulimitValues: ulimitValues{
			Soft: soft,
			Hard: hard,
		},
	}
}
870827
func NewMIME(mime string) MIME {
	kind, subtype := splitMime(mime)
	return MIME{Type: kind, Subtype: subtype, Value: mime}
}
963710
func NewSubmitMulti(fields pdutlv.Fields) Body {
	b := newSubmitMulti(&Header{ID: SubmitMultiID})
	b.init()
	for tag, value := range fields {
		b.t.Set(tag, value)
	}
	return b
}
294883
func NewSubmitMultiResp() Body {
	b := newSubmitMultiResp(&Header{ID: SubmitMultiRespID})
	b.init()
	return b
}
784997
func NewInput(name string, rate int8, specialIndex int16, numOutputs int, inputs ...Input) Input {
	var (
		expanded = expandInputs(inputs...)
		l        = len(expanded)
	)
	if l == 1 {
		return NewUgen(name, rate, specialIndex, numOutputs, inputs...)
	}
	a := make([]Input, l)
	for i := range a {
		a[i] = NewUgen(name, rate, specialIndex, numOutputs, expanded[i]...)
	}
	return Multi(a...)
}
288966
func (l *ossObjects) NewMultipartUpload(ctx context.Context, bucket, object string, o minio.ObjectOptions) (uploadID string, err error) {
	bkt, err := l.Client.Bucket(bucket)
	if err != nil {
		logger.LogIf(ctx, err)
		return uploadID, ossToObjectError(err, bucket, object)
	}

	// Build OSS metadata
	opts, err := appendS3MetaToOSSOptions(ctx, nil, o.UserDefined)
	if err != nil {
		return uploadID, ossToObjectError(err, bucket, object)
	}

	lmur, err := bkt.InitiateMultipartUpload(object, opts...)
	if err != nil {
		logger.LogIf(ctx, err)
		return uploadID, ossToObjectError(err, bucket, object)
	}

	return lmur.UploadID, nil
}
738361
func (s *ContainerProperties) SetUlimits(v []*Ulimit) *ContainerProperties {
	s.Ulimits = v
	return s
}
204619
func NewLineDelimiter(output io.Writer, delimiter string) *LineDelimiter {
	return &LineDelimiter{output: output, delimiter: []byte(delimiter)}
}
1243443
func newRandomID(n int) string {
	rand.Seed(UTCNow().UnixNano())
	sid := make([]rune, n)
	for i := range sid {
		sid[i] = letters[rand.Intn(len(letters))]
	}
	return string(sid)
}
1261997
func NewNamedUlimitOpt(name string, ref *map[string]*units.Ulimit) *NamedUlimitOpt {
	if ref == nil {
		ref = &map[string]*units.Ulimit{}
	}
	return &NamedUlimitOpt{
		name:      name,
		UlimitOpt: *NewUlimitOpt(ref),
	}
}
1233521
func newPartMetaV1(uploadID string, partID int) (partMeta *partMetadataV1) {
	p := &partMetadataV1{}
	p.Version = partMetaVersionV1
	return p
}
498575
func NewMultiTimings(name string, labels []string) *MultiTimings {
	t := &MultiTimings{
		Timings: Timings{histograms: make(map[string]*Histogram)},
		labels:  labels,
	}
	if name != "" {
		Publish(name, t)
	}
	return t
}
1163626
func (s *refsState) newCommits(c context.Context, ctl task.Controller, g *gitilesClient, ref string, maxCommits int, pathFilter pathFilter) (
	commits []*git.Commit, newRef bool, err error) {
	newHead := s.current[ref]
	oldHead, existed := s.known[ref]
	switch {
	case !existed:
		ctl.DebugLog("Ref %s is new: %s", ref, newHead)
		maxCommits = 1
		newRef = true
	case oldHead != newHead:
		ctl.DebugLog("Ref %s updated: %s => %s", ref, oldHead, newHead)
	default:
		return // no change
	}

	c, cancel := clock.WithTimeout(c, gitilesRPCTimeout)
	defer cancel()

	commits, err = gitiles.PagingLog(c, g, gitilespb.LogRequest{
		Project:            g.project,
		Committish:         newHead,
		ExcludeAncestorsOf: oldHead, // empty if ref is new, but then maxCommits is 1.
		PageSize:           int32(maxCommits),
		TreeDiff:           pathFilter.active(),
	}, maxCommits)
	switch status.Code(err) {
	case codes.OK:
		// Happy fast path.
		// len(commits) may be 0 if this ref had a force push reverting to some
		// older revision. TODO(tAndrii): consider emitting trigger with just
		// newHead commit if there is a compelling use case.
		s.known[ref] = newHead
		s.changed++
		return
	case codes.NotFound:
		// handled below.
		break
	default:
		// Any other error is presumably transient, so we'll retry.
		ctl.DebugLog("Ref %s: failed to fetch log between old %s and new %s revs", ref, oldHead, newHead)
		err = transient.Tag.Apply(err)
		return
	}
	// Either:
	//  (1) oldHead is no longer known in gitiles (force push),
	//  (2) newHead is no longer known in gitiles (eventual consistency,
	//     or concurrent force push executed just now, or ACLs change)
	//  (3) gitiles accidental 404, aka fluke.
	// In cases (2) and (3), retries should clear the problem, while (1) we
	// should handle now.
	if !existed {
		// There was no oldHead, so definitely not (1). Retry later.
		ctl.DebugLog("Ref %s: log of first rev %s not found", ref, newHead)
		err = transient.Tag.Apply(err)
		return
	}
	ctl.DebugLog("Ref %s: log old..new is not found, investigating further...", ref)

	// Fetch log of newHead only.
	var newErr error
	commits, newErr = gitiles.PagingLog(c, g, gitilespb.LogRequest{
		Project:    g.project,
		Committish: newHead,
	}, 1)
	if newErr != nil {
		ctl.DebugLog("Ref %s: failed to fetch even log of just new rev %s %s", ref, newHead, err)
		err = transient.Tag.Apply(newErr)
		return
	}
	// Fetch log of oldHead only.
	_, errOld := gitiles.PagingLog(c, g, gitilespb.LogRequest{
		Project:    g.project,
		Committish: oldHead,
		TreeDiff:   pathFilter.active(),
	}, 1)
	switch status.Code(errOld) {
	case codes.NotFound:
		// This is case (1). Since we've already fetched just 1 commit from
		// newHead, we are done.
		ctl.DebugLog("Ref %s: force push detected; emitting trigger for new head", ref)
		s.known[ref] = newHead
		s.changed++
		newRef = true
		err = nil
		return
	case codes.OK:
		ctl.DebugLog("Ref %s: weirdly, log(%s) and log(%s) work, but not log(%s..%s)",
			ref, oldHead, newHead, oldHead, newHead)
		err = transient.Tag.Apply(err)
		return
	default:
		// Any other error is presumably transient, so we'll retry.
		ctl.DebugLog("Ref %s: failed to fetch log of just old rev %s: %s", ref, oldHead, errOld)
		err = transient.Tag.Apply(err)
		return
	}
}
212114
func NewCustomSet(lessThan func(l, r interface{}) bool) *Set {
	return &Set{skiplist: SkipList{
		lessThan: lessThan,
		header: &node{
			forward: []*node{nil},
		},
		MaxLevel: DefaultMaxLevel,
	}}
}
105954
func (L *State) NewMetaTable(tname string) bool {
	Ctname := C.CString(tname)
	defer C.free(unsafe.Pointer(Ctname))
	return C.luaL_newmetatable(L.s, Ctname) != 0
}
919949
func NewMultisig(n int) *Multisignature {
	// Default the signature list to have a capacity of two, since we can
	// expect that most multisigs will require multiple signers.
	return &Multisignature{bitarray.NewCompactBitArray(n), make([][]byte, 0, 2)}
}
120062
func NewIntSet() *Set {
	return NewCustomSet(func(l, r interface{}) bool {
		return l.(int) < r.(int)
	})
}