Commit 8bb6e945 authored by teedog's avatar teedog

FOR loop invariant optimization; avoid redundant code evaluations

parent eb8a1209
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-directory_add_site.php,v 1.10 2004-03-28 07:32:23 mose Exp $
// $Header: /cvsroot/tikiwiki/tiki/tiki-directory_add_site.php,v 1.11 2004-06-16 01:43:56 teedog Exp $
// Copyright (c) 2002-2004, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
......@@ -195,8 +195,9 @@ $smarty->assign_by_ref('items', $items["data"]);
$categs = $dirlib->dir_get_all_categories_accept_sites(0, -1, 'name asc', $find, $_REQUEST["siteId"]);
if (isset($_REQUEST["save"]) && $msg != "" && isset($_REQUEST["siteCats"])) { // an error occured, the chosen categs have to be set again
$temp_max = sizeof($categs);
foreach ($_REQUEST["siteCats"] as $acat)
for ($ix = 0; $ix < sizeof($categs) ; ++$ix) {
for ($ix = 0; $ix < $temp_max ; ++$ix) {
if ($categs[$ix]["categId"] == $acat)
$categs[$ix]["belongs"] = 'y';
}
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-directory_browse.php,v 1.9 2004-03-28 07:32:23 mose Exp $
// $Header: /cvsroot/tikiwiki/tiki/tiki-directory_browse.php,v 1.10 2004-06-16 01:43:56 teedog Exp $
// Copyright (c) 2002-2004, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
......@@ -54,7 +54,8 @@ $smarty->assign_by_ref('path', $path);
// Now get the sub categories from this parent category
$categs = $dirlib->dir_list_categories($_REQUEST['parent'], 0, -1, 'name_asc', '');
for ($i = 0; $i < count($categs['data']); $i++) {
$temp_max = count($categs['data']);
for ($i = 0; $i < $temp_max; $i++) {
$categs['data'][$i]['subcats'] = array();
if ($categs['data'][$i]['childrenType'] == 'c' && $categs['data'][$i]['viewableChildren'] > 0) {
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-edit_languages.php,v 1.16 2004-04-13 10:00:41 sylvieg Exp $
// $Header: /cvsroot/tikiwiki/tiki/tiki-edit_languages.php,v 1.17 2004-06-16 01:43:56 teedog Exp $
// Copyright (c) 2002-2004, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
......@@ -107,7 +107,8 @@ if ($whataction == "edit_rec_sw" || $whataction == "edit_tran_sw") {
if (isset($_REQUEST["tr_recnum"])) {
$tr_recnum = $_REQUEST["tr_recnum"];
for ($i = $tr_recnum; $i <= $tr_recnum + $maxRecords; $i++) {
$temp_max = $tr_recnum + $maxRecords;
for ($i = $tr_recnum; $i <= $temp_max; $i++) {
// Handle edits in translate recorded
if (isset($_REQUEST["edit_rec_$i"])) {
if (strlen($_REQUEST["edit_rec_tran_$i"]) > 0 && strlen($_REQUEST["edit_rec_source_$i"]) > 0) {
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-edit_quiz.php,v 1.11 2004-04-30 23:01:59 ggeller Exp $
// $Header: /cvsroot/tikiwiki/tiki/tiki-edit_quiz.php,v 1.12 2004-06-16 01:43:46 teedog Exp $
// Copyright (c) 2002-2004, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
......@@ -212,7 +212,8 @@ $smarty->assign('find', $find);
$smarty->assign_by_ref('sort_mode', $sort_mode);
$channels = $quizlib->list_quizzes($offset, $maxRecords, $sort_mode, $find);
for ($i = 0; $i < count($channels["data"]); $i++) {
$temp_max = count($channels["data"]);
for ($i = 0; $i < $temp_max; $i++) {
if ($userlib->object_has_one_permission($channels["data"][$i]["quizId"], 'quiz')) {
$channels["data"][$i]["individual"] = 'y';
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-edit_quiz_questions.php,v 1.15 2004-05-03 04:17:06 ggeller Exp $
// $Header: /cvsroot/tikiwiki/tiki/tiki-edit_quiz_questions.php,v 1.16 2004-06-16 01:43:56 teedog Exp $
// Copyright (c) 2002-2004, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
......@@ -108,7 +108,8 @@ if (isset($_REQUEST["import"])) {
foreach ($questions as $question){
$question_text = $question->getQuestion();
$id = $quizlib->replace_quiz_question(0, $question_text, 'o', $_REQUEST["quizId"], 0);
for ($i = 0; $i < $question->getChoiceCount(); $i++){
$temp_max = $question->getChoiceCount();
for ($i = 0; $i < $temp_max; $i++){
$a = $question->GetChoice($i);
$b = $question->GetCorrect($i);
$quizlib->replace_question_option(0, $a, $b, $id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment