WebRequest: Optimise WebRequest::getPathInfo()
authorTimo Tijhof <krinklemail@gmail.com>
Mon, 2 Sep 2019 01:03:02 +0000 (02:03 +0100)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 3 Sep 2019 18:32:21 +0000 (18:32 +0000)
commitfe889b7d6b746109a981dbc300b10f98866e9007
treee8b6b7ddc459f6242ddbe2a83467ce9331ea8773
parent3420f0338c91e53139b904e13b912ef7a1c47b65
WebRequest: Optimise WebRequest::getPathInfo()

Called for all PHP web requests from WebStart.php via
WebRequest::interpolateTitle.

* Use isset() instead of empty() where we only need to check
  that the key is supported.

* Don't import global `$wgUsePathInfo` in the common case.

* Migrate from deprecated wrapper Wikimedia\suppressWarnings
  to AtEase::suppressWarnings.

* Use strpos() instead of preg_match(). Consistently faster,
  albeit not by much (for 100 iterations: 0.04ms vs 0.23ms).

* Don't create unused $matches array for the common case.

Bug: T189966
Change-Id: I0de126953c25f3629cb85a0d4e46598baf261c15
includes/WebRequest.php