X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Flibs%2FHashRing.php;h=94413c2be5c2f093d4417c0d48871916711a9ff4;hp=f8ab6a3d89045804fbb9ce195a66f5c6866e7bc4;hb=eb06fb858e8492453ddb66f9b813ef4724decced;hpb=296e3d4f98d9d277569bd1838ce56799158965c5 diff --git a/includes/libs/HashRing.php b/includes/libs/HashRing.php index f8ab6a3d89..94413c2be5 100644 --- a/includes/libs/HashRing.php +++ b/includes/libs/HashRing.php @@ -129,6 +129,12 @@ class HashRing implements Serializable { throw new InvalidArgumentException( "Invalid ring source specified." ); } + // Short-circuit for the common single-location case. Note that if there was only one + // location and it was ejected from the live ring, getLiveRing() would have error out. + if ( count( $this->weightByLocation ) == 1 ) { + return ( $limit > 0 ) ? [ $ring[0][self::KEY_LOCATION] ] : []; + } + // Locate the node index for this item's position on the hash ring $itemIndex = $this->findNodeIndexForPosition( $this->getItemPosition( $item ), $ring );