That's awesome!

Out of curiosity is there some reason to do this:
v = form[f];
       if ( structKeyExists( found, v ) ) {

Instead of this:
       if ( structKeyExists( found, form[f] ) ) {

On Thu, Oct 14, 2010 at 10:28 PM, Sean Corfield <[email protected]>wrote:

>
> On Thu, Oct 14, 2010 at 5:34 PM, Michael Grant <[email protected]> wrote:
> > The extra good news is that it also seems to be faster to use your method
> > Sean, from about two to ten times as fast. You need to be running about
> 5000
> > iterations to see any real difference, but it seems faster nonetheless.
> >
> > Thanks for that! I love (read: LOVE) learning better ways.
>
> Well, there are lots of ways of making it faster still.
>
> Using cfscript instead of tags will remove the generation of
> whitespace which will be faster.
>
> Removing the wasFound variable altogether and testing if (
> structKeyExists( found, form[x] ) ) will be faster. You only need to
> store true in the found struct (the key is the value) which will
> remove another form dereference... Converting the list (of fieldnames)
> to an array and looping over that will be faster too.
>
> <cfscript>
> // assumes ACF9 / Railo 3.2:
> timeStart = getTickCount();
> for ( a = 1; a <= iter; ++a ) {
>    found = {};
>    fields = listToArray( form.fieldNames );
>    for ( f in fields ) {
>        v = form[f];
>        if ( structKeyExists( found, v ) ) {
>            // logic to handle a duplicate
>        } else {
>            found[v] = true;
>        }
>    }
> }
> writeOutput( 'structKeyExists: ' & ( getTickCount() - timeStart ) & '<br
> />' );
> </cfscript>
> --
> Sean A Corfield -- (904) 302-SEAN
> Railo Technologies, Inc. -- http://getrailo.com/
> An Architect's View -- http://corfield.org/
>
> "If you're not annoying somebody, you're not really alive."
> -- Margaret Atwood
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:338224
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to