I'm wondering if this is some sort of flaw or maybe a known issue, it looks
like cfparam evaluates the default value every time.
<cfset x = createObject('component', 'CFIDE.adminapi.runtime')>
<cftimer label="t1" type="debug">
<cfloop from="1" to="1000" index="c">
<cfparam name="server.vals.com.lnh.system.GetInstanceNameTest"
default="#x.getInstanceName()#">
</cfloop>
</cftimer>
<cftimer label="t2" type="debug">
<cfloop from="1" to="1000" index="c">
<cfparam name="server.vals.com.lnh.system.GetInstanceNameTest"
default="#x#">
</cfloop>
</cftimer>
The first look takes significantly longer. I tried different variations,
like wrapping in toString(), etc, with no changes in behavior.
A more simplified example results the same type of behavior.
<cfset x = 1>
<cftimer label="t0" type="debug">
<cfloop from="1" to="500000" index="c">
<cfparam name="server.vals.com.lnh.system.GetInstanceNameTest"
default="#x#">
</cfloop>
</cftimer>
<cftimer label="t0" type="debug">
<cfloop from="1" to="500000" index="c">
<cfparam name="server.vals.com.lnh.system.GetInstanceNameTest"
default="1">
</cfloop>
</cftimer>
To me this kind of defeats the purpose as it should really act like
isDefined. I guess this has something to do with how templates are
compiled.
Byron Mann
Lead Engineer & Architect
HostMySite.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:356916
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm