Skip to content

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