Not signed in (Sign In)
 
Jun 8th 2008
 
Some functions used $Context or $Configuration by reference without modifying them.

It is slower than passing them by value (tested on php5.2.5 on windows and php 5.2.1 on ubuntu). The memory saved doesn't matter since the memory is free when the function exit (I guess).

Should we removed these references?
 
Jun 8th 2008 edited
 
Tested on php4 and 5... passing an object like $Context by reference or value is equally fast.

It is 2x slower for array (using count on the array) likes $Configurations when passed by reference.
 
Jun 9th 2008
 
I agree. The PHP documentation is clear that the parser is smart enough to not copy the variable passed unless necessary, and that passing by reference to attempt to improve performance is actually slower.
 
Aug 29th 2008
 
Here are the modifications Framework r169:

Index: Framework.Functions.php
===================================================================
--- Framework.Functions.php (revision 168)
+++ Framework.Functions.php (working copy)
@@ -557,7 +557,7 @@
return $FormatUrlForDisplay ? FormatStringForDisplay($FullPath) : $FullPath;
}

-function GetTableName($Key, &$TableCollection, $Prefix) {
+function GetTableName($Key, $TableCollection, $Prefix) {
if ($Key == "User") {
return $TableCollection[$Key];
} else {
@@ -565,7 +565,7 @@
}
}

-function GetUrl(&$Configuration, $PageName, $Divider = '', $Key = '', $Value = '', $PageNumber='', $Querystring='', $Suffix = '') {
+function GetUrl($Configuration, $PageName, $Divider = '', $Key = '', $Value = '', $PageNumber='', $Querystring='', $Suffix = '') {
if ($Configuration['URL_BUILDING_METHOD'] == 'mod_rewrite') {
if ($PageName == './') $PageName = 'index.php';
return $Configuration['BASE_URL']
@@ -618,7 +618,7 @@

// Checks for a custom version of the specified file
// Returns the path to the custom file (if it exists) or the default otherwise
-function ThemeFilePath(&$Configuration, $FileName) {
+function ThemeFilePath($Configuration, $FileName) {
if (file_exists($Configuration['THEME_PATH'].$FileName)) {
return $Configuration['THEME_PATH'].$FileName;
} else {
@@ -749,10 +749,11 @@
return preg_replace('![\s<"\']+!s', '', $FileName);
}

-function RenderThemeFile(&$Context, $ThemeFile) {
+function RenderThemeFile($Context, $ThemeFile) {
echo $ThemeFile;
-}
-function ReplaceThemeFile(&$Context, $Replacements, $ThemeFile) {
+}
+
+function ReplaceThemeFile($Context, $Replacements, $ThemeFile) {
$theme_file = $ThemeFile;
// Perform standard replacements
while (list($key, $replacement) = each($Replacements)) {

Issue information

  • 65
  • Dinoboff

    Dinoboff

    Bug Tracker

  • Resolved
  • Low
  • Bug

Vanilla 1.1.5 is a product of Lussumo. More Information: Documentation, Community Support.