FRemove pass by reference index shard, a=chris

Chris Pollett [2013-07-15 20:Jul:th]
FRemove pass by reference index shard, a=chris
Filename
lib/index_shard.php
lib/utility.php
diff --git a/lib/index_shard.php b/lib/index_shard.php
index cea0d4b22..2a73c9aaa 100644
--- a/lib/index_shard.php
+++ b/lib/index_shard.php
@@ -1165,7 +1165,7 @@ class IndexShard extends PersistentStructure implements
                 $copy_to_len = min($offset - $write_offset,
                     $len - $write_offset);
                 if($copy_to_len > $copy_data_len) {
-                    charCopy(&$tmp_string, $this->word_postings, $write_offset,
+                    charCopy($tmp_string, $this->word_postings, $write_offset,
                         $copy_data_len);
                     $write_offset += $copy_data_len;
                     $tmp_string = substr($tmp_string, $copy_data_len);
@@ -1183,7 +1183,7 @@ class IndexShard extends PersistentStructure implements
                             substr($this->word_postings, 0, $write_offset);
                         $this->word_postings .= $tmp_string;
                     } else {
-                        charCopy(&$tmp_string, $this->word_postings,
+                        charCopy($tmp_string, $this->word_postings,
                             $write_offset, $copy_data_len);
                         $tmp_string = substr($tmp_string, $copy_data_len);
                         $this->word_postings .= $tmp_string;
@@ -1203,7 +1203,8 @@ class IndexShard extends PersistentStructure implements
             $pad_len = $tmp_len - $copy_data_len;
             crawlLog("Completing index merge postings to string offset ".
                 "copy phase.");
-            // php auto-pads $this->word_postings with space when index $j>$len
+            $pad = str_pad("", $pad_len, "@");
+            $this->word_postings .= $pad;
             for($j = $len + $pad_len - 1,
                 $k = $len - 1; $k >= $offset; $j--, $k--) {
                 crawlTimeoutLog("..merge index postings to string final copy ".
@@ -1214,7 +1215,7 @@ class IndexShard extends PersistentStructure implements
             }
             crawlLog("Completing index merge postings to string by doing ".
                 "final charCopy of $tmp_len characters.");
-            charCopy(&$tmp_string, $this->word_postings,
+            charCopy($tmp_string, $this->word_postings,
                 $write_offset, $tmp_len, "..index shard final charCopy..");
         }

diff --git a/lib/utility.php b/lib/utility.php
index 2dee862b6..397c80aef 100755
--- a/lib/utility.php
+++ b/lib/utility.php
@@ -66,15 +66,16 @@ function addRegexDelimiters($expression)
  */
 function charCopy($source, &$destination, $start, $length, $timeout_msg = "")
 {
-    $endk = $length - 1;
-    $end = $start + $endk;
+    $endk = intval($length - 1);
+    $end = intval($start + $endk);
+    $start = intval($start);
     if($timeout_msg == "") {
         for($j = $end, $k = $endk; $j >= $start; $j--, $k--) {
-            $destination[(int)$j] = $source[(int)$k];
+            $destination[$j] = $source[$k];
         }
     } else {
         for($j = $end, $k = $endk; $j >= $start; $j--, $k--) {
-            $destination[(int)$j] = $source[(int)$k];
+            $destination[$j] = $source[$k];
             crawlTimeoutLog($timeout_msg);
         }
     }
ViewGit