Skip to content

[minor] SCA #26938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 20, 2018
Merged

[minor] SCA #26938

merged 1 commit into from
Apr 20, 2018

Conversation

kalessil
Copy link
Contributor

Q A
Branch? 2.7
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR n/a
  • Control flow tweaks

}

return false;
return class_exists($class) || interface_exists($class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while at it, the second call should have false as second argument

@@ -56,8 +56,7 @@ public function __construct($name, $shortcut = null, $mode = null, $description
if (is_array($shortcut)) {
$shortcut = implode('|', $shortcut);
}
$shortcuts = preg_split('{(\|)-?}', ltrim($shortcut, '-'));
$shortcuts = array_filter($shortcuts);
$shortcuts = array_filter(preg_split('{(\|)-?}', ltrim($shortcut, '-')));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No performance gain, just fewer lines of code to maintain.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, performing two distinct operations in two lines of code is easier to understand than performing two distinct operations in one line of code.

The number of lines of code to be maintained is less of an issue than the ability for the code to be easily understood.

I'd say this specific change is better being reverted to the two line version.

Copy link
Contributor Author

@kalessil kalessil Apr 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll revert, since benefits are questionable.

Regarding the argumentation we should distinguish business logic (where I'll agree with you) and low-level stuff like strings manipulation (which is normally needs diving into in any case).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicolas-grekas nicolas-grekas added this to the 2.7 milestone Apr 17, 2018
@nicolas-grekas
Copy link
Member

Thank you @kalessil.

@nicolas-grekas nicolas-grekas merged commit 877e678 into symfony:2.7 Apr 20, 2018
nicolas-grekas added a commit that referenced this pull request Apr 20, 2018
This PR was squashed before being merged into the 2.7 branch (closes #26938).

Discussion
----------

[minor] SCA

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

- Control flow tweaks

Commits
-------

877e678 [minor] SCA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants