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

performance take1: use array access for non multibyte string offsets #43

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Mar 20, 2021

this didn't worked out as I initially thought.. for discussion and maybe inspiration purposes I figured it might still be usefull to open a PR

@@ -39,7 +39,12 @@ public function take1(): TakeResult
{
$this->guardEndOfStream();

$token = mb_substr($this->string, 0, 1);
$ord = \ord($this->string[0]);
Copy link
Contributor Author

@staabm staabm Mar 20, 2021

Choose a reason for hiding this comment

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

in case we would have a non-multibyte-StringStream in which the ord-call would not be necessary (because multi byte strings dont need to be supported), a $this->string[0] would be way faster then a substr($this->string, 0, 1);

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.

None yet

1 participant