From 7869546fef7b2ea5fd6fd72feacd565a7f177fb6 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Fri, 10 May 2019 08:47:00 +0100 Subject: [PATCH] Speed up reveal widget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It turns out that the `localeCompare` function used by `compareStateText()` is very, very slow. Replacing it with a straightforward equality test makes one of my test rigs be 10x faster... Note that this PR reverts the behaviour of match/nomatch to that before #3157. That change was not backwards compatible in that the switch to localeCompare meant that é === e, now it doesn't again. --- core/modules/widgets/reveal.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/modules/widgets/reveal.js b/core/modules/widgets/reveal.js index f5511f4b3..e89377186 100755 --- a/core/modules/widgets/reveal.js +++ b/core/modules/widgets/reveal.js @@ -142,10 +142,10 @@ RevealWidget.prototype.readState = function() { this.readPopupState(state); break; case "match": - this.isOpen = !!(this.compareStateText(state) == 0); + this.isOpen = this.text === state; break; case "nomatch": - this.isOpen = !(this.compareStateText(state) == 0); + this.isOpen = this.text !== state; break; case "lt": this.isOpen = !!(this.compareStateText(state) < 0);