Use isset in permission exists for improved efficiency(#7126)

Using isset on the key name of the array allows it to use a hash table lookup to improve the lookup times for a permission. The permission name is not set if it does not exist for the current user.
This commit is contained in:
frytimo
2024-09-09 12:14:45 -03:00
committed by GitHub
parent 04125ef651
commit 2085c950ee

View File

@@ -127,21 +127,12 @@ if (!class_exists('permissions')) {
return true;
}
//set default to false
$result = false;
//search for the permission
if (!empty($this->permissions) && !empty($permission_name)) {
foreach($this->permissions as $key => $value) {
if ($key == $permission_name) {
$result = true;
break;
}
}
if (!empty($permission_name)) {
return isset($this->permissions[$permission_name]);
}
//return the result
return $result;
return false;
}
/**