From 68c5d761a8ccf90a6cb463036483ebb7f05aecd5 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 6 Jun 2016 00:25:48 +0200 Subject: [PATCH] #5849 #5850 minor performance optimization - avoiding `get_class()` calls on all entity insertions --- lib/Doctrine/ORM/UnitOfWork.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 8efeb9e8f..7044ce57e 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -3477,7 +3477,8 @@ class UnitOfWork implements PropertyChangedListener private function clearEntityInsertionsForEntityName($entityName) { foreach ($this->entityInsertions as $hash => $entity) { - if (get_class($entity) === $entityName) { + // note: performance optimization - `instanceof` is much faster than a function call + if ($entity instanceof $entityName && get_class($entity) === $entityName) { unset($this->entityInsertions[$hash]); } }