Skip to content

Commit

Permalink
[Performance] Use strlen() early before loop on VendorMissAnalyseGuard (
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik authored Feb 10, 2024
1 parent 77ec96e commit 6d408f5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Configuration/VendorMissAnalyseGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ private function hasDowngradeSets(): bool
*/
private function containsVendorPath(array $filePaths): bool
{
$cwd = PathNormalizer::normalize(getcwd());
$cwdLength = strlen(PathNormalizer::normalize(getcwd()));

foreach ($filePaths as $filePath) {
$normalizedPath = PathNormalizer::normalize(realpath($filePath));
if (str_starts_with(substr($normalizedPath, strlen($cwd)), '/vendor/')) {
if (str_starts_with(substr($normalizedPath, $cwdLength), '/vendor/')) {
return true;
}
}
Expand Down

0 comments on commit 6d408f5

Please sign in to comment.