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

[TASK] Iterate over characters #21

Merged
merged 2 commits into from
May 23, 2022
Merged

[TASK] Iterate over characters #21

merged 2 commits into from
May 23, 2022

Conversation

CDRO
Copy link

@CDRO CDRO commented May 16, 2022

As discussed on typo3.slack.com, here's my contribution to improving the performance of finediff.

The complexity of splitting a string once into an array and iterating over it is O(2n) as where having to mb_substr for each character is O(n^2). This can lead to quite harsh performance issues when trying to calculate a diff for longer texts.

See the TYPO3 [TypoScript Tokenizer][1] for another example of this implementation.
[1]: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74285/28..29/typo3/sysext/core/Classes/TypoScript/Tokenizer/Tokenizer.php

Tizian Schmidlin added 2 commits May 16, 2022 14:54
The complexity of splitting a string once into an array and iterating over it is O(2n) as where having to `mb_substr` for each character is O(n^2). This can lead to quite harsh performance issues when trying to calculate a diff for longer texts.

See the TYPO3 [TypoScript Tokenizer][1] for another example of this implementation.
[1]: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74285/28..29/typo3/sysext/core/Classes/TypoScript/Tokenizer/Tokenizer.php
@lolli42 lolli42 merged commit 03b7926 into lolli42:main May 23, 2022
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.

2 participants