LanguageConverter performance: Reuse the same string object for regexp
authorC. Scott Ananian <cscott@cscott.net>
Tue, 2 Jul 2019 18:04:39 +0000 (14:04 -0400)
committerC. Scott Ananian <cscott@cscott.net>
Tue, 2 Jul 2019 18:32:01 +0000 (14:32 -0400)
commit25512652d289b02fa90268f9ff06ba094af6781d
treea59b15c09bb02c65ca8f086c336da8756d269363
parent930efa63e1db7634f69b3e798da80933ab42db4a
LanguageConverter performance: Reuse the same string object for regexp

The regular expression used by LanguageConverter::autoConvert() is a
constant, but it is being created on-the-fly by every invocation.
This causes an expensive full-string comparison when the compiled
regular expression is fetched from the cache -- since the regex is 332
bytes long, the time taken for this comparison can add up quickly: on
page with a lot of tags, the regexp cache may spend more time looking
up the regexp than it takes to execute it.

Bug: T223969
Change-Id: I53c3e631e47a791cf3f0844dd79d4357605c59e3
languages/LanguageConverter.php