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

Get rid of ctype #206

Merged
merged 1 commit into from
Jan 19, 2023
Merged

Get rid of ctype #206

merged 1 commit into from
Jan 19, 2023

Conversation

alecpl
Copy link
Contributor

@alecpl alecpl commented Mar 28, 2021

Even if 1-2% slower it does not depend on system locale as ctype functions. Polyfills are even slower.

Fixes #173

{
$code = ord($input);

return ($code >= 97 && $code <= 122) || ($code >= 65 && $code <= 90);
Copy link
Contributor

Choose a reason for hiding this comment

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

to import readability of the code, you might replace the numbers with \ord('A') and so on. PHP optimizes such calls (qualified calls to ord with a static string as argument) at compile time, so the runtime is the same than putting the number directly. But it makes it easier to understand what the code is about (as it avoids magic numbers)

Copy link
Member

Choose a reason for hiding this comment

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

👍

@goetas goetas closed this Jan 11, 2023
@goetas goetas reopened this Jan 11, 2023
@goetas goetas merged commit 3d02e3a into Masterminds:master Jan 19, 2023
@goetas
Copy link
Member

goetas commented Jan 19, 2023

the suggested improvement can be done later, i'm merging this. I want to prepare a new release soon

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

Successfully merging this pull request may close these issues.

Get rid of ctype dependency
3 participants