// final returns the current state symbol without decoding the next.
972836
func (s *fseState) final() (int, uint8) {
	return int(s.state.baseline), s.state.addBits
}
448132
func (ctrl *Controller) Finish() {
	ctrl.T.Helper()

	ctrl.mu.Lock()
	defer ctrl.mu.Unlock()

	if ctrl.finished {
		ctrl.T.Fatalf("Controller.Finish was called more than once. It has to be called exactly once.")
	}
	ctrl.finished = true

	// If we're currently panicking, probably because this is a deferred call,
	// pass through the panic.
	if err := recover(); err != nil {
		panic(err)
	}

	// Check that all remaining expected calls are satisfied.
	failures := ctrl.expectedCalls.Failures()
	for _, call := range failures {
		ctrl.T.Errorf("missing call(s) to %v", call)
	}
	if len(failures) != 0 {
		ctrl.T.Fatalf("aborting test due to missing call(s)")
	}
}
1111106
func (m *MediaTypeDefinition) Finalize() {
	if m.ContentType == "" {
		m.ContentType = m.Identifier
	}
	m.UserTypeDefinition.Finalize()
}
228259
func (e *Entry) finalize(level Level, msg string) *Entry {
	return &Entry{
		Logger:    e.Logger,
		Fields:    e.mergedFields(),
		Level:     level,
		Message:   msg,
		Timestamp: Now(),
	}
}
530800
func (d *ResourceDiff) finalizeResult(addr []string, result FieldReadResult) getResult {
	// If the result doesn't exist, then we set the value to the zero value
	var schema *Schema
	if schemaL := addrToSchema(addr, d.schema); len(schemaL) > 0 {
		schema = schemaL[len(schemaL)-1]
	}

	if result.Value == nil && schema != nil {
		result.Value = result.ValueOrZero(schema)
	}

	// Transform the FieldReadResult into a getResult. It might be worth
	// merging these two structures one day.
	return getResult{
		Value:          result.Value,
		ValueProcessed: result.ValueProcessed,
		Computed:       result.Computed,
		Exists:         result.Exists,
		Schema:         schema,
	}
}
329180
func (m *Message) Finish() {
	if !atomic.CompareAndSwapInt32(&m.responded, 0, 1) {
		return
	}
	m.Delegate.OnFinish(m)
}
521810
func (t *SecondaryTree) Last() (k RouteInfo, v *FinalizerList) {
	if q := t.last; q != nil {
		q := &q.d[q.c-1]
		k, v = q.k, q.v
	}
	return
}
784346
func Finalize(finalizers ...Finalizer) error {
	var errs ErrorGroup
	for _, finalizer := range finalizers {
		errs.Add(finalizer.Finalize())
	}
	return errs.Finalize()
}
253218
func (c Chain) Final(fn HandlerFunc) HandlerFunc {
	for i := len(c.middlewareHandlers) - 1; i >= 0; i-- {
		fn = c.middlewareHandlers[i](fn)
	}
	return fn
}
1138445
func (d *Decoder) Finish() ([]byte, error) {
	// If we've ever seen an error, just return that again.
	if d.err != nil {
		return nil, d.err
	}
	if int64(len(d.buf)) >= d.packetLen {
		panic("decoder buffer has more bytes than expected")
	}
	// If we've been truncated at a packet boundary, this open will fail on a
	// simple length check. If we've been truncated in the middle of a packet,
	// this open will fail to validate.
	var plaintext []byte
	plaintext, d.err = d.openOnePacket(int64(len(d.buf)))
	return plaintext, d.err
}
926706
func (c *cache) finalizer() {
	if c.mmap != nil {
		c.mmap.Unmap()
		c.dump.Close()
		c.mmap, c.dump = nil, nil
	}
}
596350
func (megaPi *Adaptor) Finalize() error {
	megaPi.finalizeChannel <- struct{}{}
	<-megaPi.finalizeChannel
	if err := megaPi.connection.Close(); err != nil {
		return err
	}
	return nil
}
1185730
func (u *UserTypeDefinition) Finalize() {
	if u.Reference != nil {
		if bat := u.AttributeDefinition; bat != nil {
			u.AttributeDefinition.Inherit(bat)
		}
	}

	u.GenerateExample(Design.RandomGenerator(), nil)
}
268350
func (t *tree) Last() (k uint64, v *Container) {
	if q := t.last; q != nil {
		q := &q.d[q.c-1]
		k, v = q.k, q.v
	}
	return k, v
}
102692
func Finalize(bundle Bundle) (Bundle, error) {
	var valueTrits = make([]Trits, len(bundle))
	var timestampTrits = make([]Trits, len(bundle))
	var currentIndexTrits = make([]Trits, len(bundle))
	var obsoleteTagTrits = make([]Trits, len(bundle))
	var lastIndexTrits = PadTrits(IntToTrits(int64(bundle[0].LastIndex)), 27)

	for i := range bundle {
		valueTrits[i] = PadTrits(IntToTrits(bundle[i].Value), 81)
		timestampTrits[i] = PadTrits(IntToTrits(int64(bundle[i].Timestamp)), 27)
		currentIndexTrits[i] = PadTrits(IntToTrits(int64(bundle[i].CurrentIndex)), 27)
		obsoleteTagTrits[i] = PadTrits(MustTrytesToTrits(bundle[i].ObsoleteTag), 81)
	}

	var bundleHash Hash
	for {
		k := kerl.NewKerl()

		for i := 0; i < len(bundle); i++ {
			relevantTritsForBundleHash := MustTrytesToTrits(
				bundle[i].Address +
					MustTritsToTrytes(valueTrits[i]) +
					MustTritsToTrytes(obsoleteTagTrits[i]) +
					MustTritsToTrytes(timestampTrits[i]) +
					MustTritsToTrytes(currentIndexTrits[i]) +
					MustTritsToTrytes(lastIndexTrits),
			)
			k.Absorb(relevantTritsForBundleHash)
		}

		bundleHashTrits, err := k.Squeeze(HashTrinarySize)
		if err != nil {
			return nil, err
		}
		bundleHash = MustTritsToTrytes(bundleHashTrits)

		// check whether normalized bundle hash can be computed
		normalizedBundleHash := signing.NormalizedBundleHash(bundleHash)
		ok := true
		for i := range normalizedBundleHash {
			if normalizedBundleHash[i] == 13 {
				ok = false
				break
			}
		}
		if ok {
			break
		}
		obsoleteTagTrits[0] = AddTrits(obsoleteTagTrits[0], Trits{1})
	}

	// set the computed bundle hash on each tx in the bundle
	for i := range bundle {
		tx := &bundle[i]
		if i == 0 {
			tx.ObsoleteTag = MustTritsToTrytes(obsoleteTagTrits[0])
		}
		tx.Bundle = bundleHash
	}

	return bundle, nil
}
907865
func (aw *AnsiWriter) finish(parse func([]byte) error) error {
	var err error

	if parse != nil {
		err = parse(aw.buf[2:])
	}

	aw.buf = nil
	return err
}
973474
func (d *dataset) finalizer() {
	if d.mmap != nil {
		d.mmap.Unmap()
		d.dump.Close()
		d.mmap, d.dump = nil, nil
	}
}