Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: Passing Params

by Anonymous Monk
on Jan 17, 2001 at 01:00 UTC ( [id://52353]=note: print w/replies, xml ) Need Help??


in reply to Re: Passing Params
in thread Passing Params

Would passing $query to the subroutine have the fastest execution of the above methods?

Replies are listed 'Best First'.
Re: Re: Re: Passing Params
by chromatic (Archbishop) on Jan 17, 2001 at 01:17 UTC
    From where I sit, yes. The overhead of creating a new CGI object is not trivial. It has to read the query string or STDIN (if it can, I don't remember offhand if it caches it) to get parameters, setting things up to be retrieved at will.

    Creating a hash means allocating memory and hashing keys you may or may not use.

    Passing in $query means dereferencing the object to call a method on it.

    Depending on how many parameters you have and how many things you need to call and if you can get by with sticking things in a hash just once and you don't want sticky fields behavior that CGI.pm does so nicely, I'd give the edge to passing in $query. Sometimes I pass a hash.

    This is unlikely to be the largest bottleneck in your program, however.

Re: Re: Re: Passing Params
by sutch (Curate) on Jan 17, 2001 at 01:04 UTC
    I would tend to think that passing $query (which is a reference to an existing CGI query object) is much faster than creating a hash or another new CGI query object.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://52353]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-03-29 06:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found