]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/lists/class_BaseList.php
Continued:
[core.git] / framework / main / classes / lists / class_BaseList.php
index c1ac982eb154c8381622ff828c8107b193bf856a..edca181d6fa99913340a9ec8abb481fb5abd05f9 100644 (file)
@@ -61,6 +61,14 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
         */
        private $listIndex = [];
 
+       /**
+        * Cached values from "expensive" method calls
+        */
+       private $cache = [
+               // Cached isValidHash() calls
+               'is_valid' => [],
+       ];
+
        /**
         * Protected constructor
         *
@@ -403,13 +411,13 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
                if (empty($hash)) {
                        // Throw IAE
                        throw new InvalidArgumentException('Parameter "hash" is empty');
+               } elseif (!isset($this->cache['is_valid'][$hash])) {
+                       // Check it
+                       $this->cache['is_valid'][$hash] = ((in_array($hash, $this->listIndex)) && (isset($this->listEntries[$hash])));
                }
 
-               // Check it
-               $isValid = ((in_array($hash, $this->listIndex)) && (isset($this->listEntries[$hash])));
-
                // Return the result
-               return $isValid;
+               return $this->cache['is_valid'][$hash];
        }
 
        /**