mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR: faster checking if record exists
Rather than using a loop through each object, we just filter for it in the SQL query. This is likely to speed up the code and also make it more legible.
This commit is contained in:
parent
73ef035bd8
commit
9660652fbc
@ -924,15 +924,8 @@ class Member extends DataObject
|
||||
}
|
||||
|
||||
$groupCandidateObjs = ($strict) ? $this->getManyManyComponents("Groups") : $this->Groups();
|
||||
if ($groupCandidateObjs) {
|
||||
foreach ($groupCandidateObjs as $groupCandidateObj) {
|
||||
if ($groupCandidateObj->ID == $groupCheckObj->ID) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return $groupCandidateObjs->filter(['ID' => $groupCheckObj->ID])->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user