From 1bc3f3b065d60fc74be31a1816f12099d885f464 Mon Sep 17 00:00:00 2001 From: Santhosh Thottingal Date: Mon, 9 May 2016 11:51:42 +0530 Subject: [PATCH] Compact links: Avoid duplicate call of filterByCommonLanguages It re-triggers mw.uls.getFrequentLanguageList(), getPreviousLanguages() and localstorage read. In this patch the result was saved and reused. Bug: T122341 Change-Id: I14839eb611cd3e995e8d8ab729ee3f714840f9ad --- resources/js/ext.uls.compactlinks.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/resources/js/ext.uls.compactlinks.js b/resources/js/ext.uls.compactlinks.js index 91469468..9ab0df1f 100644 --- a/resources/js/ext.uls.compactlinks.js +++ b/resources/js/ext.uls.compactlinks.js @@ -47,6 +47,7 @@ this.options = options || {}; this.interlanguageList = {}; this.compactList = {}; + this.commonInterlanguageList = null; this.$trigger = null; this.compactSize = 0; this.listSize = 0; @@ -175,7 +176,7 @@ compact: true, languages: ulsLanguageList, // Show common languages - quickList: self.filterByCommonLanguages( languages ) + quickList: self.getCommonLanguages( languages ) } ); }, @@ -234,7 +235,7 @@ // Add all common languages to the beginning of array. // These are the most probable languages predicted by ULS. - this.filterByCommonLanguages( languages ), + this.getCommonLanguages( languages ), // Finally add the whole languages array too. // We will remove duplicates and cut down to required size. @@ -320,6 +321,13 @@ return interlanguageList; }, + /** + * Get common languages - the most probable languages predicted by ULS. + */ + getCommonLanguages: function ( languages ) { + return this.commonInterlanguageList || this.filterByCommonLanguages( languages ); + }, + /** * Hide the original interlanguage list */