From: <var...@us...> - 2022-02-16 16:53:31
|
Revision: 11003 http://sourceforge.net/p/phpwiki/code/11003 Author: vargenau Date: 2022-02-16 16:53:28 +0000 (Wed, 16 Feb 2022) Log Message: ----------- Use count instead of sizeof Modified Paths: -------------- trunk/lib/diff3.php trunk/lib/difflib.php trunk/lib/mimelib.php trunk/lib/plugin/Chart.php trunk/lib/plugin/DebugGroupInfo.php trunk/lib/plugin/WikicreoleTable.php Modified: trunk/lib/diff3.php =================================================================== --- trunk/lib/diff3.php 2022-02-15 18:23:37 UTC (rev 11002) +++ trunk/lib/diff3.php 2022-02-16 16:53:28 UTC (rev 11003) @@ -102,7 +102,7 @@ private function append(&$array, $lines) { - array_splice($array, sizeof($array), 0, $lines); + array_splice($array, count($array), 0, $lines); } public function input($lines) Modified: trunk/lib/difflib.php =================================================================== --- trunk/lib/difflib.php 2022-02-15 18:23:37 UTC (rev 11002) +++ trunk/lib/difflib.php 2022-02-16 16:53:28 UTC (rev 11003) @@ -36,12 +36,12 @@ public function norig() { - return $this->orig ? sizeof($this->orig) : 0; + return $this->orig ? count($this->orig) : 0; } public function nfinal() { - return $this->final ? sizeof($this->final) : 0; + return $this->final ? count($this->final) : 0; } } @@ -145,8 +145,8 @@ public function diff($from_lines, $to_lines) { - $n_from = sizeof($from_lines); - $n_to = sizeof($to_lines); + $n_from = count($from_lines); + $n_to = count($to_lines); $this->xchanged = $this->ychanged = array(); $this->xv = $this->yv = array(); @@ -190,7 +190,7 @@ } // Find the LCS. - $this->compareseq(0, sizeof($this->xv), 0, sizeof($this->yv)); + $this->compareseq(0, count($this->xv), 0, count($this->yv)); // Merge edits when possible $this->shift_boundaries($from_lines, $this->xchanged, $this->ychanged); @@ -421,9 +421,9 @@ $i = 0; $j = 0; - assert('sizeof($lines) == sizeof($changed)'); - $len = sizeof($lines); - $other_len = sizeof($other_changed); + assert('count($lines) == count($changed)'); + $len = count($lines); + $other_len = count($other_changed); while (1) { /* @@ -574,7 +574,7 @@ foreach ($this->edits as $edit) { if ($edit->orig) - array_splice($lines, sizeof($lines), 0, $edit->orig); + array_splice($lines, count($lines), 0, $edit->orig); } return $lines; } @@ -593,7 +593,7 @@ foreach ($this->edits as $edit) { if ($edit->final) - array_splice($lines, sizeof($lines), 0, $edit->final); + array_splice($lines, count($lines), 0, $edit->final); } return $lines; } @@ -630,8 +630,8 @@ $mapped_from_lines, $mapped_to_lines) { - assert(sizeof($from_lines) == sizeof($mapped_from_lines)); - assert(sizeof($to_lines) == sizeof($mapped_to_lines)); + assert(count($from_lines) == count($mapped_from_lines)); + assert(count($to_lines) == count($mapped_to_lines)); parent::__construct($mapped_from_lines, $mapped_to_lines); @@ -638,17 +638,17 @@ $xi = $yi = 0; // Optimizing loop invariants: // http://phplens.com/lens/php-book/optimizing-debugging-php.php - for ($i = 0, $max = sizeof($this->edits); $i < $max; $i++) { + for ($i = 0, $max = count($this->edits); $i < $max; $i++) { $orig = &$this->edits[$i]->orig; if (is_array($orig)) { - $orig = array_slice($from_lines, $xi, sizeof($orig)); - $xi += sizeof($orig); + $orig = array_slice($from_lines, $xi, count($orig)); + $xi += count($orig); } $final = &$this->edits[$i]->final; if (is_array($final)) { - $final = array_slice($to_lines, $yi, sizeof($final)); - $yi += sizeof($final); + $final = array_slice($to_lines, $yi, count($final)); + $yi += count($final); } } } @@ -702,7 +702,7 @@ foreach ($diff->edits as $edit) { if ($edit->type == 'copy') { if (is_array($block)) { - if (sizeof($edit->orig) <= $nlead + $ntrail) { + if (count($edit->orig) <= $nlead + $ntrail) { $block[] = $edit; } else { if ($ntrail) { @@ -718,9 +718,9 @@ $context = $edit->orig; } else { if (!is_array($block)) { - $context = array_slice($context, max(0, sizeof($context) - $nlead)); - $x0 = $xi - sizeof($context); - $y0 = $yi - sizeof($context); + $context = array_slice($context, max(0, count($context) - $nlead)); + $x0 = $xi - count($context); + $y0 = $yi - count($context); $block = array(); if ($context) $block[] = new DiffOp_Copy($context); @@ -729,9 +729,9 @@ } if ($edit->orig) - $xi += sizeof($edit->orig); + $xi += count($edit->orig); if ($edit->final) - $yi += sizeof($edit->final); + $yi += count($edit->final); } if (is_array($block)) Modified: trunk/lib/mimelib.php =================================================================== --- trunk/lib/mimelib.php 2022-02-15 18:23:37 UTC (rev 11002) +++ trunk/lib/mimelib.php 2022-02-16 16:53:28 UTC (rev 11003) @@ -282,7 +282,7 @@ $m[1], rawurldecode($reference)); } - if (sizeof($footnotes) > 0) { + if (count($footnotes) > 0) { ksort($footnotes); return "-----\n" . "!" . _("References") . "\n" Modified: trunk/lib/plugin/Chart.php =================================================================== --- trunk/lib/plugin/Chart.php 2022-02-15 18:23:37 UTC (rev 11002) +++ trunk/lib/plugin/Chart.php 2022-02-16 16:53:28 UTC (rev 11003) @@ -101,7 +101,7 @@ // y_min = 0 or smallest element in data if negative // y_max = biggest element in data - $x_max = sizeof($values) + 1; + $x_max = count($values) + 1; $y_min = min($values); if ($y_min > 0) { $y_min = 0; Modified: trunk/lib/plugin/DebugGroupInfo.php =================================================================== --- trunk/lib/plugin/DebugGroupInfo.php 2022-02-15 18:23:37 UTC (rev 11002) +++ trunk/lib/plugin/DebugGroupInfo.php 2022-02-16 16:53:28 UTC (rev 11003) @@ -59,7 +59,7 @@ foreach ($allGroups as $g) { $members = $group->getMembersOf($g); $output->pushContent(HTML::h2($g . " - members: " . - sizeof($members) . " - isMember: " . ($group->isMember($g) ? "yes" : "no") + count($members) . " - isMember: " . ($group->isMember($g) ? "yes" : "no") )); $list = HTML::ul(); foreach ($members as $m) { Modified: trunk/lib/plugin/WikicreoleTable.php =================================================================== --- trunk/lib/plugin/WikicreoleTable.php 2022-02-15 18:23:37 UTC (rev 11002) +++ trunk/lib/plugin/WikicreoleTable.php 2022-02-16 16:53:28 UTC (rev 11003) @@ -96,7 +96,7 @@ } } - $nb_rows = sizeof($table); + $nb_rows = count($table); // If table is empty, do not generate table markup if ($nb_rows == 0) { return HTML::raw(''); @@ -105,7 +105,7 @@ // Number of columns is the number of cells in the longer row $nb_cols = 0; for ($i = 0; $i < $nb_rows; $i++) { - $nb_cols = max($nb_cols, sizeof($table[$i])); + $nb_cols = max($nb_cols, count($table[$i])); } for ($i = 0; $i < $nb_rows; $i++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |