//Optimized applyCachedImpulse
337682
func (arb *Arbiter) applyCachedImpulse(dt_coef vect.Float) {
	if arb.state == arbiterStateFirstColl && arb.NumContacts > 0 {
		return
	}
	//println("asd")
	a := arb.ShapeA.Body
	b := arb.ShapeB.Body
	var j vect.Vect

	for _, con := range arb.Contacts {
		//transform.RotateVect(con.n, transform.Rotation{con.jnAcc, con.jtAcc})
		j.X = ((con.n.X * con.jnAcc) - (con.n.Y * con.jtAcc)) * dt_coef
		j.Y = ((con.n.X * con.jtAcc) + (con.n.Y * con.jnAcc)) * dt_coef

		//apply_impulses(a, b, con.r1, con.r2, vect.Mult(j, dt_coef))
		a.v.X = (-j.X * a.m_inv) + a.v.X
		a.v.Y = (-j.Y * a.m_inv) + a.v.Y
		a.w += a.i_inv * ((con.r1.X * -j.Y) - (con.r1.Y * -j.X))

		b.v.X = (j.X * b.m_inv) + b.v.X
		b.v.Y = (j.Y * b.m_inv) + b.v.Y

		b.w += b.i_inv * ((con.r2.X * j.Y) - (con.r2.Y * j.X))
	}
}
1117976
func (s *DisjunctionHeapSearcher) Optimize(kind string, octx index.OptimizableContext) (
	index.OptimizableContext, error) {
	if len(s.searchers) == 1 {
		o, ok := s.searchers[0].(index.Optimizable)
		if ok {
			return o.Optimize(kind, octx)
		}
	}

	return octx, nil
}
34864
func (f *fragment) FlushCache() error {
	f.mu.Lock()
	defer f.mu.Unlock()
	return f.flushCache()
}
501818
func (s *NodeGroupMember) SetCacheClusterId(v string) *NodeGroupMember {
	s.CacheClusterId = &v
	return s
}
717905
func (h *hawkularSink) cache(md *metrics.MetricDefinition) {
	h.pushToCache(md.ID, hashDefinition(md))
}
120584
func (n *nomadFSM) applyUpsertVaultAccessor(buf []byte, index uint64) interface{} {
	defer metrics.MeasureSince([]string{"nomad", "fsm", "upsert_vault_accessor"}, time.Now())
	var req structs.VaultAccessorsRequest
	if err := structs.Decode(buf, &req); err != nil {
		panic(fmt.Errorf("failed to decode request: %v", err))
	}

	if err := n.state.UpsertVaultAccessor(index, req.Accessors); err != nil {
		n.logger.Error("UpsertVaultAccessor failed", "error", err)
		return err
	}

	return nil
}
85610
func (ctx *Context) ApplyPatchFull(output io.Writer, pool Pool, ops chan Operation, failFast bool) error {
	for op := range ops {
		err := ctx.ApplySingleFull(output, pool, op, failFast)
		if err != nil {
			return errors.WithStack(err)
		}
	}

	return nil
}
260673
func (c *Controller) updateSpecLocked() error {
	crdSpecs := []*spec.Swagger{}
	for _, versionSpecs := range c.crdSpecs {
		for _, s := range versionSpecs {
			crdSpecs = append(crdSpecs, s)
		}
	}
	return c.openAPIService.UpdateSpec(mergeSpecs(c.staticSpec, crdSpecs...))
}
33773
func NewCache(duration time.Duration) *Cache {
	cache := &Cache{
		ttl:   duration,
		items: map[string]*Item{},
	}
	cache.startCleanupTimer()
	return cache
}
415696
func NewBatchedLoader(batchFn BatchFunc, opts ...Option) *Loader {
	loader := &Loader{
		batchFn:  batchFn,
		inputCap: 1000,
		wait:     16 * time.Millisecond,
	}

	// Apply options
	for _, apply := range opts {
		apply(loader)
	}

	// Set defaults
	if loader.cache == nil {
		loader.cache = NewCache()
	}

	if loader.tracer == nil {
		loader.tracer = &NoopTracer{}
	}

	return loader
}
1057579
func (cb *configBased) CheckCache(mts []core.Metric, id string) ([]core.Metric, []core.Metric) {
	if _, ok := cb.metricCache[id]; !ok {
		cb.metricCache[id] = NewCache(cb.cacheTTL)
	}
	return cb.metricCache[id].checkCache(mts)
}
23118
func (s *CreateDeploymentInput) SetCacheClusterEnabled(v bool) *CreateDeploymentInput {
	s.CacheClusterEnabled = &v
	return s
}
269614
func (c *CacheLazyFill) FillCache() error {
	allApps, err := c.fetchEntityListFromAPI("apps")
	if err != nil {
		return err
	}

	// Populate bolt with all apps
	for guid, app := range allApps {
		// Canonicalise the guid
		u, err := uuid.FromString(guid)
		if err != nil {
			return err
		}
		uuid := u.String()

		// Save our app out
		err = c.normaliseAndSaveEntityToDatabase("apps", uuid, app)
		if err != nil {
			return err
		}

		// Fetch and poulate space and org
		_, _, err = c.getSpaceAndOrg(app.SpaceGUID)
		if err != nil {
			return err
		}
	}

	return nil
}
509831
func (p *pool) applyPluginMeta(a AvailablePlugin) error {
	// Checking if plugin is exclusive
	// (only one instance should be running).
	if a.Exclusive() {
		p.max = 1
	}

	// Set the cache TTL
	cacheTTL := GlobalCacheExpiration
	// if the plugin exposes a default TTL that is greater the the global default use it
	if a.CacheTTL() != 0 && a.CacheTTL() > GlobalCacheExpiration {
		cacheTTL = a.CacheTTL()
	}

	// Set the concurrency count
	p.concurrencyCount = a.ConcurrencyCount()

	// Set the routing and caching strategy
	switch a.RoutingStrategy() {
	case plugin.DefaultRouting:
		p.RoutingAndCaching = NewLRU(cacheTTL)
	case plugin.StickyRouting:
		p.RoutingAndCaching = NewSticky(cacheTTL)
		p.concurrencyCount = 1
	case plugin.ConfigRouting:
		p.RoutingAndCaching = NewConfigBased(cacheTTL)
	default:
		return ErrBadStrategy
	}

	return nil
}
537341
func (cacher *txSenderCacher) cache() {
	for task := range cacher.tasks {
		for i := 0; i < len(task.txs); i += task.inc {
			types.Sender(task.signer, task.txs[i])
		}
	}
}
1255732
func (w *watchCache) updateCache(event *watchCacheEvent) {
	if w.endIndex == w.startIndex+w.capacity {
		// Cache is full - remove the oldest element.
		w.startIndex++
	}
	w.cache[w.endIndex%w.capacity] = event
	w.endIndex++
}
1015009
func (opts *ReadOptions) SetFillCache(value bool) {
	C.rocksdb_readoptions_set_fill_cache(opts.c, boolToChar(value))
}