Clancy schreef:
> I have a function to process a data file.  This process opens the file, and 
> then calls
> another function to process each entry.  This function in turn calls another 
> function to
> process each line of the entry.  A set of fairly complex arrays specifies how 
> all the
> possible types of entries and lines should be processed, and each function 
> passes sections
> of these arrays to the next function.
> Is it better to pass the parameters by value, in which case they have to be 
> copied into
> yet more memory when the function is called, or to pass by reference, which I 
> suspect may
> involve additional overhead every time they are accessed?
> And is it better to combine several specifications arrays into one more 
> complex array, and
> pass a single parameter, or to pass them individually as half a dozen 
> different
> parameters?
> I suspect that I am probably asking a "how long is a piece of string?" type 
> of question,
> but are there any general rules which are applicable to this type of 
> situation?

by reference is pointless (and less performant IIRC) unless the input will be 
php does copy-on-write magic under the hood.

one complex param or many simpler ones? I doubt either makes any difference, 
down to personal preference. ask yourself: "will I still grok all this 
magic/params 12 months from now?"

I might suggest you look into a refactoring the code to use an object, and have 
it store
the parsing config/spec centrally as a property which each of the functions 
you mentioned can then read.

in dutch they have a silly saying: "'How Long' is a chinaman."


PHP General Mailing List (
To unsubscribe, visit:

Reply via email to