소스 검색

More trivial changes for HashRing::add and HashRing::remove.

Daniele Alessandri 15 년 전
부모
커밋
f811877c87
1개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. 4 2
      lib/Predis.php

+ 4 - 2
lib/Predis.php

@@ -832,7 +832,8 @@ class HashRing {
 
     public function add($node) {
         $nodeHash = (string) $node;
-        for ($i = 0; $i < $this->_replicas; $i++) {
+        $replicas = $this->_replicas;
+        for ($i = 0; $i < $replicas; $i++) {
             $key = crc32($nodeHash . ':' . $i);
             $this->_ring[$key] = $node;
         }
@@ -842,7 +843,8 @@ class HashRing {
 
     public function remove($node) {
         $nodeHash = (string) $node;
-        for ($i = 0; $i < $this->_replicas; $i++) {
+        $replicas = $this->_replicas;
+        for ($i = 0; $i < $replicas; $i++) {
             $key = crc32($nodeHash . ':' . $i);
             unset($this->_ring[$key]);
             $this->_ringKeys = array_filter($this->_ringKeys, function($rk) use($key) {