func (fc *FCache) remap(indexes map[interface{}]*keyMap, ent *entry) {
	keys := make([]Key, len(ent.content.Keys))

	// Step through the existing keys
	for i, k := range ent.content.Keys {
		// Handle unmutated key
		km, ok := indexes[k.Index]
		if !ok {
			keys[i] = k
			continue
		}

		// OK, construct the new key
		keys[i] = Key{
			Index: k.Index,
			Key:   km.new,
		}

		// Delete the old entry
		delete(km.idx.entries, km.old)

		// Check for a squatter
		e, ok := km.idx.entries[km.new]
		if ok {
			// Try to complete the squatter
			if e.content == nil {
				defer e.complete(ent.content)
				continue
			}

			// OK, have to evict the old entry
			fc.evict(e.content.Keys)
		}

		// Replace with the new entry
		km.idx.entries[km.new] = ent
	}

	// Update the entry keys
	ent.content.Keys = keys
}
// remap is a helper that applies the finalized key map to the cache.
// The cache MUST be locked upon entry to this method.
remap is a helper that applies the finalized key map to the cache.
The cache MUST be locked upon entry to this method.
// remap is a helper that applies the finalized key map to the cache . // The cache MUST be locked upon entry to this method .
func (fc *FCache) remap(indexes map[interface{}]*keyMap, ent *entry) {
	keys := make([]Key, len(ent.content.Keys))
	for i, k := range ent.content.Keys {
		km, ok := indexes[k.Index]
		if !ok {
			keys[i] = k
			continue
		}
		keys[i] = Key{
			Index: k.Index,
			Key:   km.new,
		}
		delete(km.idx.entries, km.old)
		e, ok := km.idx.entries[km.new]
		if ok {
			if e.content == nil {
				defer e.complete(ent.content)
				continue
			}
			fc.evict(e.content.Keys)
		}
		km.idx.entries[km.new] = ent
	}
	ent.content.Keys = keys
}
func ( fc * FCache ) remap ( indexes map [ interface { } ] * keyMap , ent * entry ) { keys := make ( [ ] Key , len ( ent . content . Keys ) ) for i , k := range ent . content . Keys { km , ok := indexes [ k . Index ] if ! ok { keys [ i ] = k continue } keys [ i ] = Key { Index : k . Index , Key : km . new , } delete ( km . idx . entries , km . old ) e , ok := km . idx . entries [ km . new ] if ok { if e . content == nil { defer e . complete ( ent . content ) continue } fc . evict ( e . content . Keys ) } km . idx . entries [ km . new ] = ent } ent . content . Keys = keys }
remap is a helper that applies the finalized key map to the cache.
remap is a helper that applies the finalized key map to the cache .
// Step through the existing keys // Handle unmutated key // OK, construct the new key // Delete the old entry // Check for a squatter // Try to complete the squatter // OK, have to evict the old entry // Replace with the new entry // Update the entry keys