Przeglądaj źródła

Optymalizacja BiAuditGenerate

Mariusz Muszyński 8 lat temu
rodzic
commit
c329de3618
1 zmienionych plików z 10 dodań i 7 usunięć
  1. 10 7
      SE/se-lib/Route/UrlAction/BiAuditGenerate.php

+ 10 - 7
SE/se-lib/Route/UrlAction/BiAuditGenerate.php

@@ -2418,13 +2418,16 @@ class BiAuditPowiazania {
 	}
 
 	private static function weightCalc($n) {
-		static $weights = [];
-		if (!isset($weights[$n])) {
-			$weight = floor(log(($n - 1) / 10) / log(2)) + 1;
-			if ($weight < 1) $weight = 1;
-			$weights[$n] = $weight;
-		}
-		return $weights[$n];
+		if ($n < 21) return 1;
+		if ($n < 41) return 2;
+		if ($n < 81) return 3;
+		if ($n < 161) return 4;
+		if ($n < 321) return 5;
+		if ($n < 641) return 6;
+		if ($n < 1281) return 7;
+		if ($n < 2561) return 8;
+		if ($n < 5121) return 9;
+		return 10;
 	}
 
 	public function findPowiazania($ID, $progress = 0, $steps = 1, $relation = "", $weight = 0) {