Skip to content
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

Optimization: Don't repeatedly check unchanging value #811

Closed
bookwyrm opened this issue Sep 22, 2021 · 1 comment
Closed

Optimization: Don't repeatedly check unchanging value #811

bookwyrm opened this issue Sep 22, 2021 · 1 comment

Comments

@bookwyrm
Copy link
Contributor

https://github.com/leonstafford/wp2static/blob/84f1d33bcadbe0a7c485a72c8528b5703f147454/src/FilesHelper.php#L60

The value of $site_path doesn't change while we iterate over files in the filesystem, but we're checking the value each time.

Since if we have a non-string value for $site_path we won't ever get any files, it would be better to pull this check out before the iterator an simply short-circuit the iterator and return an empty array if $site_path is not a string.

@bookwyrm bookwyrm changed the title Optimization: Don't check unchanging value Optimization: Don't repeatedly check unchanging value Sep 22, 2021
@leonstafford
Copy link
Contributor

💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants