From 7cc484dd320e01a265fa6557146d43f3e05b58b3 Mon Sep 17 00:00:00 2001 From: Roman Tymoshyk Date: Tue, 11 Aug 2015 19:24:01 +0300 Subject: [PATCH] Performance improvement in PropelObjectCollection Reduced count of excess conditions in loop --- runtime/lib/collection/PropelObjectCollection.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/runtime/lib/collection/PropelObjectCollection.php b/runtime/lib/collection/PropelObjectCollection.php index 265da242f..07dd69877 100644 --- a/runtime/lib/collection/PropelObjectCollection.php +++ b/runtime/lib/collection/PropelObjectCollection.php @@ -299,16 +299,10 @@ public function contains($element) private function getIdenticalObject(BaseObject $object) { - $objectHashCode = null; + $objectHashCode = $object->hashCode(); foreach ($this as $obj) { - if ($obj instanceof BaseObject) { - if (null === $objectHashCode) { - $objectHashCode = $object->hashCode(); - } - - if ($obj->hashCode() === $objectHashCode) { - return $obj; - } + if ($obj instanceof BaseObject && $obj->hashCode() === $objectHashCode) { + return $obj; } }