Thiemo Mättig (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/155757

Change subject: Refactor nested loop in entityViewInit
......................................................................

Refactor nested loop in entityViewInit

Change-Id: I5555f65725b623bb0407cd5290c702376489989a
---
M repo/resources/wikibase.ui.entityViewInit.js
1 file changed, 7 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/57/155757/1

diff --git a/repo/resources/wikibase.ui.entityViewInit.js 
b/repo/resources/wikibase.ui.entityViewInit.js
index 1c7e464..1d1b37a 100644
--- a/repo/resources/wikibase.ui.entityViewInit.js
+++ b/repo/resources/wikibase.ui.entityViewInit.js
@@ -297,20 +297,20 @@
                        var group = $( this ).data( 'wb-sitelinks-group' ),
                                groupSiteIds = [],
                                $sitesCounterContainer = $( '<span/>' ),
-                               siteLinks = entity.getSiteLinks(),
+                               siteLinks = {},
                                siteLinksOfGroup = [];
 
                        $.each( wb.sites.getSitesOfGroup( group ), function( 
siteId, site ) {
                                groupSiteIds.push( siteId );
                        } );
 
+                       $.each( entity.getSiteLinks(), function( i, siteLink ) {
+                               siteLinks[siteLink.getSiteId()] = siteLink;
+                       } );
+
                        for( var i = 0; i < siteIdsOfGroup.length; i++ ) {
-                               for( var j = 0; j < siteLinks.length; j++ ) {
-                                       if( siteLinks[j].getSiteId() === 
siteIdsOfGroup[i] ) {
-                                               siteLinksOfGroup.push( 
siteLinks[j] );
-                                               break;
-                                       }
-                               }
+                               var siteId = siteIdsOfGroup[i];
+                               siteLinks[siteId] && siteLinksOfGroup.push( 
siteLinks[siteId] );
                        }
 
                        $( this ).prev().append( $sitesCounterContainer );

-- 
To view, visit https://gerrit.wikimedia.org/r/155757
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5555f65725b623bb0407cd5290c702376489989a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to