While this method is not a huge bottleneck in this codebase it still
sticks out because it calls end() and array_pop() literally millions
of times. (Tested by running the unit test suite, which currently
takes about 30 seconds on my machine.)
Because of the way the method is used in this codebase (see especially
ImmutableRange::computePosition) $a is almost always a sub-element of
$b, or the other way around. It's almost never necessary to go all the
way up to the root element. We can use this additional knowledge and
stop much, much earlier. The extra code is worth it because we know it
will succeed very, very often.
When I measure the runtime of this method alone it goes down to less
than 1% of the previous runtime. The final loop at the end of the
method is almost never executed now (about 30 times in 15,000).
I also micro-benchmarked the final loop and optimized it to work with
passive array-indexes instead of actively manipulating the array with
array_pop().
Change-Id: Iffcaa8848780a85fde38e322649050c687567f29
It does the same as before.
I think performance is not a concern here, and wasn't my motivation
either. But I hope this makes the code easier to read and to reason
with.
I added a pure unit test case (without involving an actual Language
object) to cover the previously uncovered digits feature.
Change-Id: I6a0fc86035817eabb42b55e58183ae094c052aa6
I was curious why running the CommentParserTest takes so long. I
found this is one of the bottlenecks because it's called so often,
but many link titles that are parsed as user names turn out to be
something else. This little hack speeds up the test by 15% and has
probably a similar impact in production scenarios.
Change-Id: I5a0b3a49ba5793c8a345baaa7118fed500c082b6
I was curious why running some of the PHPUnit tests in this code base
takes so long. While I could not spot an obvious bottleneck I found
a lot of code that is extremely hot, e.g. called a hundred thousand
times. A few obvious optimizations are possible in this code, e.g.
not calling the surprisingly expensive DOMCompat::getClassList
multiple times.
Change-Id: If22bbc1aedd2c36db1ab2343de5737009050b7bb
There is nothing in this preg_replace call that needs to be executed
"as code". A normal preg_replace can do the same.
The pattern looks a bit different but really does have the exact same
effect as before.
Change-Id: I3597d632f2ecbe5b7ccef39a394075327c9bea79
These are not widely used anywhere, but linking to an #h- heading ID
that doesn't exist should say "topic not found" rather than
"comment not found".
Change-Id: Ifd269cc72e640f36431f85c751874ca06229ba9f
Replacing legacy breakpoint variables with new Codex
design system `@max-width-breakpoint-*` tokens.
Bug: T331403
Change-Id: Ib1ff07a7692948b1fd22e9620c132133d392dab9
Saying that ctrl-enter would submit the post at a moment when it
wouldn't may be confusing to users.
Bug: T326500
Change-Id: Ib513c8a6c36a0f607cc2034fc830dbfcdf10f554
We support highlighter HeadingItem's despite saying CommentItem
in a bunch of places.
Also potentially show the "not found" notification if the URL hash
starts "h-" as well as "c-".
Change-Id: I51894902bfca405bbdec89806bb9c1d76e0b40ef
All features should be enabled by default for 3rd party installs.
I74ecd243 ensures this will have no effect on WMF wikis.
Depends-On: I74ecd2438c86d99b5727de488c928cc7d37da6db
Change-Id: Ia3245902abf2601f53065f1ffb94133d7b25e223
MediaWiki's PHPCS plugin requires documentation comments on all
properties, unless those properties are typed.
This has potential to introduce bugs – in particular, because typed
properties without a default value will throw an exception if their
value is accessed before it's defined, while previously they defaulted
to null. I fixed this when I found it (making them nullable and null
by default), but I may have missed some cases.
Change-Id: If5b1f4d542ce3e1b69327ee4283f7c3e133a62a0