viewgit/inc/functions.php:22 Function utf8_encode() is deprecated [8192]

speed up unique record case getWordInfoTier, a=chris

Chris Pollett [2018-06-19 23:Jun:th]
speed up unique record case getWordInfoTier, a=chris
Filename
src/library/IndexDictionary.php
diff --git a/src/library/IndexDictionary.php b/src/library/IndexDictionary.php
index 7fede1723..fae5f8348 100644
--- a/src/library/IndexDictionary.php
+++ b/src/library/IndexDictionary.php
@@ -840,7 +840,9 @@ class IndexDictionary implements CrawlConstants
             return false;
         }
         $prefix_tmp = unpack("N*", $prefix_info);
-        if (!isset($prefix_tmp[2]) || !$prefix_tmp[2]) {return false; }
+        if (!isset($prefix_tmp[2]) || !$prefix_tmp[2]) {
+            return false;
+        }
         $aux_prefix_bit = (ord($word_id[0]) & 128) ? 0 : 32768;
         list(, $offset, $high) = $prefix_tmp;
         $high--;
@@ -854,7 +856,9 @@ class IndexDictionary implements CrawlConstants
             $word_string = $this->getDictSubstring($file_num, $start +
                 $check_loc * $word_item_len, $word_item_len);
             $num_aux_records = 0;
-            if ($word_string == false) {return false;}
+            if ($word_string == false) {
+                return false;
+            }
             // next 'if' handles finding start of a record with aux records
             $word_prefix = (ord($word_string[0]) << 8) + ord($word_string[1]);
             if ($aux_prefix_bit == ($word_prefix & 32768)) {
@@ -867,11 +871,15 @@ class IndexDictionary implements CrawlConstants
                     $word_prefix =
                         (ord($word_string[0]) << 8) + ord($word_string[1]);
                     // if this is not start of dictionary record fail
-                    if ($aux_prefix_bit == ($word_prefix & 32768)) { break; }
+                    if ($aux_prefix_bit == ($word_prefix & 32768)) {
+                        break;
+                    }
                     $num_aux_records = (ord($word_string[$word_key_len]) << 8) +
                         ord($word_string[$word_key_len + 1]);
                     $check_loc += 1 + $num_aux_records;
-                    if ($check_loc > $high) { break; }
+                    if ($check_loc > $high) {
+                        break;
+                    }
                     $word_string =
                         $this->getDictSubstring($file_num, $start +
                         $check_loc * $word_item_len, $word_item_len);
@@ -928,6 +936,11 @@ class IndexDictionary implements CrawlConstants
                 }
             }
         }
+        // if shift is 0 then at most one record in dictionary matches
+        if ($shift == 0) {
+            $this->formatWordInfo($total_count, $max_retained_generation,
+                $info);
+        }
         //up to first record with word id
         $test_loc = $check_loc - 1;
         $start_loc = $check_loc;
ViewGit