code: func (proxier *Proxier) updateEndpointsMap() (result updateEndpointMapResult) {
  	result.staleEndpoints = make(map[endpointServicePair]bool)
  	result.staleServiceNames = make(map[proxy.ServicePortName]bool)
  
  	var endpointsMap proxyEndpointsMap = proxier.endpointsMap
  	var changes *endpointsChangeMap = &proxier.endpointsChanges
  
  	func() {
  		changes.lock.Lock()
  		defer changes.lock.Unlock()
  		for _, change := range changes.items {
  			endpointsMap.unmerge(change.previous, proxier.serviceMap)
  			endpointsMap.merge(change.current, proxier.serviceMap)
  		}
  		changes.items = make(map[types.NamespacedName]*endpointsChange)
  	}()
  
  	// TODO: If this will appear to be computationally expensive, consider
  	// computing this incrementally similarly to endpointsMap.
  	result.hcEndpoints = make(map[types.NamespacedName]int)
  	localIPs := getLocalIPs(endpointsMap)
  	for nsn, ips := range localIPs {
  		result.hcEndpoints[nsn] = len(ips)
  	}
  
  	return result
  }
docs: // <endpointsMap> is updated by this function (based on the given changes).
  // <changes> map is cleared after applying them.