Permalink
Browse files

performance MDL-25637 some of more similar performance tweaks to come

  • Loading branch information...
1 parent 17e0390 commit f179cdb73e65ea92f8b67767d119f2d388a40b94 @nebgor nebgor committed Dec 10, 2010
View
@@ -129,15 +129,17 @@ function delete_dir_contents ($dir,$excludeddir="") {
}
// Delete all files in the curent directory return false and halt if a file cannot be removed
- for($i=0; $i<count($dir_files); $i++) {
+ $countdirfiles = count($dir_files);
+ for($i=0; $i<$countdirfiles; $i++) {
chmod($dir_files[$i], $CFG->directorypermissions);
if (((unlink($dir_files[$i]))) == FALSE) {
return false;
}
}
// Empty sub directories and then remove the directory
- for($i=0; $i<count($dir_subdirs); $i++) {
+ $countdirsubdirs = count($dir_subdirs);
+ for($i=0; $i<$countdirsubdirs; $i++) {
chmod($dir_subdirs[$i], $CFG->directorypermissions);
if (delete_dir_contents($dir_subdirs[$i]) == FALSE) {
return false;
View
@@ -377,7 +377,8 @@ function restore_create_blogs($restore,$xml_file) {
$tagsarr = $info['BLOG']['#']['BLOG_TAGS']['0']['#']['BLOG_TAG'];
//Iterate over tags
$tags = array();
- for($i = 0; $i < sizeof($tagsarr); $i++) {
+ $sizetagsarr = sizeof($tagsarr);
+ for($i = 0; $i < $sizetagsarr; $i++) {
$tag_info = $tagsarr[$i];
///traverse_xmlize($tag_info); //Debug
///print_object ($GLOBALS['traverse_array']); //Debug
@@ -119,7 +119,8 @@ function get_analysed($item, $groupid = false, $courseid = false) {
$analysedAnswer = array();
if($info->subtype == 'c') {
- for($i = 1; $i <= sizeof($answers); $i++) {
+ $sizeofanswers = sizeof($answers);
+ for($i = 1; $i <= $sizeofanswers; $i++) {
$ans = null;
$ans->answertext = $answers[$i-1];
$ans->answercount = 0;
@@ -136,7 +137,8 @@ function get_analysed($item, $groupid = false, $courseid = false) {
$analysedAnswer[] = $ans;
}
}else {
- for($i = 1; $i <= sizeof($answers); $i++) {
+ $sizeofanswers = sizeof($answers);
+ for($i = 1; $i <= $sizeofanswers; $i++) {
$ans = null;
$ans->answertext = $answers[$i-1];
$ans->answercount = 0;
@@ -167,7 +169,8 @@ function get_printval($item, $value) {
if($info->subtype == 'c') {
$vallist = array_values(explode (FEEDBACK_MULTICHOICE_LINE_SEP, $value->value));
- for($i = 0; $i < sizeof($vallist); $i++) {
+ $sizeofvallist = sizeof($vallist);
+ for($i = 0; $i < $sizeofvallist; $i++) {
for($k = 0; $k < sizeof($presentation); $k++) {
if($vallist[$i] == ($k + 1)) {//Die Werte beginnen bei 1, das Array aber mit 0
$printval .= trim($presentation[$k]) . chr(10);
View
@@ -187,7 +187,8 @@
}
$xmlentries = $xml['GLOSSARY']['#']['INFO'][0]['#']['ENTRIES'][0]['#']['ENTRY'];
- for($i = 0; $i < sizeof($xmlentries); $i++) {
+ $sizeofxmlentries = sizeof($xmlentries);
+ for($i = 0; $i < $sizeofxmlentries; $i++) {
// Inserting the entries
$xmlentry = $xmlentries[$i];
unset($newentry);
@@ -247,7 +248,8 @@
$importedentries++;
$xmlaliases = @$xmlentry['#']['ALIASES'][0]['#']['ALIAS']; // ignore missing ALIASES
- for($k = 0; $k < sizeof($xmlaliases); $k++) {
+ $sizeofxmlaliases = sizeof($xmlaliases);
+ for($k = 0; $k < $sizeofxmlaliases; $k++) {
/// Importing aliases
$xmlalias = $xmlaliases[$k];
$aliasname = $xmlalias['#']['NAME'][0]['#'];
@@ -263,7 +265,8 @@
if (!empty($data->catsincl)) {
// If the categories must be imported...
$xmlcats = @$xmlentry['#']['CATEGORIES'][0]['#']['CATEGORY']; // ignore missing CATEGORIES
- for($k = 0; $k < sizeof($xmlcats); $k++) {
+ $sizeofxmlcats = sizeof($xmlcats);
+ for($k = 0; $k < $sizeofxmlcats; $k++) {
$xmlcat = $xmlcats[$k];
$newcat = new stdClass();
View
@@ -110,7 +110,8 @@
// want to allow <b><i>(maybe more) tags but when we do that
// the preg_match messes up.
preg_match_all("/(<([\w]+)[^>]*>)([^<\\2>]*)(<\/\\2>)/", $string, $matches);
- for($i = 0; $i < count($matches[1]); $i++) { // go through all of our div matches
+ $countmatches = count($matches[1]);
+ for($i = 0; $i < $countmatches; $i++) { // go through all of our div matches
$class = lesson_importppt_isolate_class($matches[1][$i]); // first step in isolating the class
@@ -207,4 +208,4 @@
echo $OUTPUT->box_start('generalbox boxaligncenter');
$mform->display();
echo $OUTPUT->box_end();
-echo $OUTPUT->footer();
+echo $OUTPUT->footer();
@@ -300,8 +300,9 @@ function ouwiki_line($data,$linepos) {
$pos=0;
while(true) {
// Find a non-space
- for(;$pos < strlen($data) && substr($data,$pos,1)===' ';$pos++) ;
- if($pos==strlen($data)) {
+ $strlendata = strlen($data);
+ for(;$pos < $strlendata && substr($data,$pos,1)===' ';$pos++) ;
+ if($pos==$strlendata) {
// No more content
break;
}
@@ -527,7 +528,8 @@ function internal_find_deletes($diff,$count2) {
// resulting array will be -,-,3,3,3,-,0
$squidges=array();
$lowest=0;
- for($index1=count($diff);$index1>=1;$index1--) {
+ $countdiff = count($diff);
+ for($index1=$countdiff;$index1>=1;$index1--) {
$index2=$diff[$index1];
if($index2===0) {
$squidges[$index1]=$lowest;
@@ -142,7 +142,8 @@ private function get_table_cells($string) {
$cells = array();
foreach($normalcells as $nc) {
$headercells = explode("!!", $nc);
- for($i = 0; $i < count($headercells); $i++) {
+ $countheadercells = count($headercells);
+ for($i = 0; $i < $countheadercells; $i++) {
$cells[] = array($type, $headercells[$i]);
$type = 'header';
}

0 comments on commit f179cdb

Please sign in to comment.