php - Returning value versus passing object references -


at point suggested me sluggishness in php script partly because returning large array function. instead suggested passing object reference function , having function working directly on array.

if makes significant difference i'm planning on changing function style returning array of information regarding function execution (time benchmark, attempts etc.) , working directly on object reference instead.

so think?

no, not make difference.

php implements copy-on-write, meaning if assign value variable or return function, value passed reference internally. it's being copied when written to, , if there no other variables referencing it. since you're returning array function, no other variables should reference array, hence there's no copying going on @ point.

php lot of optimization regards pointers, references , variable handling. don't think can outsmart easily, php high-level that. write mean. , always: profile find real bottlenecks.


Comments