We’ve already been over this, but this can have performance implications when used with highly iterative operations.  Consider this (contrived, but simple) example:

 

function add(a, b) {

            var local = StructNew();

            local.result = arguments.a + arguments.b;

            return local.result;

}

 

Now if you’re running that in a loop like so:

 

<cfloop from=”1” to=”10000” index=”i”>

            <cfset result = add(i, 100)>

</cfloop>

 

You’ve just created and destroyed 10,000 structs!!!  That’s a heck of a lot of object creation and garbage collection.  It really depends on the application as to whether or not it is something to be concerned about, however, since in most applications, this type of massive iteration does not really occur.

 

Roland

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jim Davis
Sent: Thursday, November 10, 2005 3:03 PM
To: [email protected]
Subject: RE: [CFCDev] Scoping Error

 

You might also create a pseudo scope to get around this.

 

I do <cfset var local = structnew() /> at the top of every method.  Then later instead of doing “<cfset var sFacade …. />” you can do “<cfset local.sFacade … />”

 

Doing this also offers the benefit of being able to dump the local “scope” for debugging.

 

Jim Davis

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).

An archive of the CFCDev list is available at www.mail-archive.com/[email protected] ----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).

An archive of the CFCDev list is available at www.mail-archive.com/[email protected]

Reply via email to