I am reviewing a colleague's code and have noticed something that I think is inefficient and wasteful.
Basically he has a function like this:
function blah($record) {
echo "do something " . $record['first_name'] . $record['last_name'];
}
He is passing an entire array to this function without about 30 odd records.
Inside the function he only ever uses $record['first_name'] and $record['last_name'] so all the other attributes are pointless.
My argument is. Wouldn't it be better to rewrite it like this:
function blah($first_name, $last_name) {
echo "Do something " . $first_name . $last_name;
}
And then simply use the parameters instead of accessing the array during the function.
Is this an accurate observation? Will memory be shallow copied by php unnecessarily in this instance? Or am I being over pedantic.