From e15d5024bbc8dc245367cd30e00643634478ca27 Mon Sep 17 00:00:00 2001 From: Dan Hemberger Date: Wed, 24 Jan 2018 13:49:56 -0800 Subject: [PATCH] Begin the crusade against references See #317. In strict PHP, you can only assign variables by reference. Things that are not variables include function calls and constants. So we begin the herculean task of removing all unneeded references. Here are some important details about references: * Objects are always passed/copied by reference (in the c++ sense). We can pass an object without the `&` and still access/modify its internal data. * Arrays are passed/copied by value, but not really because of copy-on-write, which means that it will only make a copy of the array if you try to modify it. * References disable copy-on-write. If you have an array that was copied by value, and then you take a reference to it, you will immediately make a copy of it, even if the reference doesn't modify that array. >>> Moral of the story <<< Do not use references in an attempt to improve performance. PHP does all the right performance things behind the scenes _if_ you are using the language in the intended way. References are only intended for when you truly want to pass something to another function and have that function modify it. For more details, see http://schlueters.de/blog/archives/125-Do-not-use-PHP-references.html --- templates/Default/engine/Default/includes/Missions.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/Default/engine/Default/includes/Missions.inc b/templates/Default/engine/Default/includes/Missions.inc index 27abca093..86fa1dec9 100644 --- a/templates/Default/engine/Default/includes/Missions.inc +++ b/templates/Default/engine/Default/includes/Missions.inc @@ -4,9 +4,9 @@ if(isset($MissionMessage)) { ?> echo $MissionMessage; } -$AvailableMissions =& $ThisPlayer->getAvailableMissions(); +$AvailableMissions = $ThisPlayer->getAvailableMissions(); if(count($AvailableMissions) > 0) { - foreach($AvailableMissions as $MissionID => &$AvailableMission) { ?> + foreach($AvailableMissions as $MissionID => $AvailableMission) { ?> New Mission:

 Accept 

0) { } -$Missions =& $ThisPlayer->getActiveMissions(); +$Missions = $ThisPlayer->getActiveMissions(); if(count($Missions) > 0) { - foreach($Missions as $MissionID => &$Mission) { + foreach($Missions as $MissionID => $Mission) { if(in_array($MissionID, $UnreadMissions)) { ?> Task Complete: