Skip to content

Commit

Permalink
Merge pull request #18 from TysonAndre/perf-improve
Browse files Browse the repository at this point in the history
Improve performance when checking long words for typos
  • Loading branch information
TysonAndre committed Mar 27, 2020
2 parents da01163 + c2df516 commit e554dce
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/TypoCheckUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static function getTyposForText(string $contents, bool $plaintext = false
$suggestions = $dictionary[strtolower($word)] ?? null;
if ($suggestions === null) {
// Analyze anything resembling camelCase, CamelCase, or snake_case
if (preg_match('/(?:[a-z].*[A-Z]|_)/', $word)) {
if (preg_match('/(?:[a-z][A-Z]|_)/', $word)) {
preg_match_all('/[a-z]+|[A-Z](?:[a-z]+|[A-Z]+(?![a-z]))/', $word, $matches);
if (count($matches[0]) >= 2) {
foreach ($matches[0] as $inner_word) {
Expand Down

0 comments on commit e554dce

Please sign in to comment.