Skip to content

Commit 5fad8e3

Browse files
committed
add little performance improvement
1 parent d80ca5f commit 5fad8e3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Datastructure/Table/HashTable.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ public function countPerBucket() {
380380

381381
/**
382382
* returns the hash table as an array
383+
*
383384
* @return array
384385
*/
385386
public function toArray(): array {
@@ -443,16 +444,17 @@ public function getNodeByKey($key): ?Node {
443444
* the list is requested from the array based on
444445
* the array index hash.
445446
*/
446-
/** @var SinglyLinkedList $list */
447447
if (!isset($this->bucket[$arrayIndex])) {
448448
return null;
449449
}
450+
/** @var AbstractLinkedList $list */
450451
$list = $this->bucket[$arrayIndex];
451-
if (!$list->containsKey($key)) {
452+
453+
if (!$list instanceof AbstractLinkedList) {
452454
return null;
453455
}
454-
$node = $list->getNodeByKey($key);
455-
return $node;
456+
457+
return $list->getNodeByKey($key);
456458
}
457459

458460
/**

0 commit comments

Comments
 (0)