On Wed, 10 May 2006 15:21:14 +0000 (UTC), DongerNeedFood
wrote:
> I tried a couple of solutions:
>
> First, I made the array positions be the list index
values instead of the
> actual ID.
>
> So instead of: cfset xrayzones1 = 0
>
> I used: cfset xrayzones1 = 0
>
> This solution improved processing time dramatically and
decreased mem usage.
> But I wanted to see if structures would improve it more.
>
> My second attempt involved using structures to declare
my zones. Ultimately,
> I went with structures because it produced the fastest
processing time. My
> processing time went from ~8seconds to 0.35seconds.
Here's the code:
>
> <cfset theid = "i#i#q#q#z#z#">
> <cfset a = structinsert(zones1,theid,0)>
You could more closely replicate your original array-based
code with a
couple of quick mods.
<cfset zones = structNew()>
<cfset zones[1] = structNew()>
<cfloop list="#id_lst#" index="i">
<cfset zones[1]
= structNew()>
<cfloop list="#qstn_list#" index="q">
<cfset zones[1]
quote:
= structNew()>
<cfloop list="#zone_list#" index="z">
<cfset zones[1]
quote:
= 0>
</cfloop>
</cfloop>
</cfloop>
<cfset zones[2] = duplicate(zones[1])>
<cfset zones[3] = duplicate(zones[1])>
<cfset zones[4] = duplicate(zones[1])>
Obviously if the real assignment logic is more complex than
creating four
identical structs, all holding some keys with value 0, then
this
duplicate() bit won't work, but you get my point, I'm sure.
--
Adam