IMO this would be better:

        private function getMetadataForClass($entity)
        {
            $em = $this->registry->getManagerForClass($entity);

            if ($em === null) {
                return new ClassMetadataCollection(array());
            }

            $class = $this->getClassMetadataFactoryClass();
            $cmf = new $class();
            $cmf->setEntityManager($em);

            $metadata = $cmf->getMetadataFor($entity);

            return new ClassMetadataCollection(array($metadata));
        }

A random microtime diff test on a small app(~15 entities, 1 manager), for a single entity:
current(in lib): float(0.25397801399231)
after: float(0.003140926361084)

@michaelperrin :+1: , this would improve speed a lot for a large app