I haven't scrutinized your code, but when I can't get a troublesome routine to
run any more quickly, I often cache its result in a persistent scope
("application" is my favorite). That's one way to sweep it under the rug.
Jamie
> Hi all. I'm building an app using model glue and reactor. I'm having
> an issue with a function I wrote that returns my navigation to me,
> appropriately nested. The function is a recursive one, and works as
> designed, no problem there. BUT, it's painfully slow, even with
> debugging and reactor regeneration disabled. SO, I'm wondering if any
> of you can look at how I've approached this and tell me if anything
> jumps out at you as obviously inefficient. Thanks!
>
> The specs:
>
> End value returned:
>
> <div id="menu0">Administration</div>
> <div id="menu1">view reports</div>
> <div id="menu1">search employees</div>
> <div id="menu2">easy on the bottom line</div>
> <div id="menu1">enrollment stats</div>
> <div id="menu1">system reports</div>
> <div id="menu1">Company profile</div>
> <div id="menu1">manage system users</div>
> <div id="menu1">message center</div>
> <div id="menu0">Enrollment</div>
> <div id="menu1">new hire enrollment</div>
> <div id="menu1">life status event</div>
> <div id="menu1">view current benefits</div>
> <div id="menu0">About Us</div>
> <div id="menu0">Cwes features</div>
> <div id="menu1">streamlined open enrollment</div>
> <div id="menu1">customizable reports</div>
> <div id="menu1">ease of use</div>
> <div id="menu1">one stop shop</div>
> <div id="menu0">Contact Us</div>
>
>
>
> My nav table structure:
>
> NavigationID (primary key, auto incrementing integer);
> name (varchar, name of my nav item);
> output_text (varchar, text to use for the nav item);
> link (varchar, link for the nav item);
> parentid (integer, ID of the parent navigation item (=
> navigationID));
> navorder (tinyint, sort order for navigation)
>
>
>
> The CFC performing the nav building:
>
> <cfcomponent displayname="Controller" output="false" hint="I am a
> sample model-glue controller." extends="ModelGlue.Core.Controller">
>
> <cfset variables.reactor = application.recordfactory />
> <cfset variables.navcontainer = "" />
>
> <cffunction name="Init" access="Public" returnType="controller.
> navcontroller" output="false" hint="I build a new SampleController">
> <cfargument name="ModelGlue" required="true" type="ModelGlue.
> ModelGlue" />
> <cfargument name="InstanceName" required="true" type="string" />
> <cfset super.Init(arguments.ModelGlue) />
> <cfreturn this />
> </cffunction>
>
> <cffunction name="getNav" access="public" returnType="void"
> output="false">
> <cfargument name="event" type="ModelGlue.Core.Event"
> required="false">
> <cfargument name="parentID" type="numeric" required="yes"
> default=0
> />
> <cfargument name="level" type="numeric" required="yes"
> default=0 />
> <cfset var objNav = "" />
> <cfset var objItem = "" />
> <!--- grab all the elements whose parent is
> 'arguments.parentID'
> --->
> <cfset objNav = variables.reactor.creategateway("navparent").
> getByFields(parentid=arguments.parentid) />
> <!--- loop through query --->
>
> <cfloop query="objNav">
> <!--- add this item to global variable --->
> <cfset variables.navcontainer = variables.navcontainer
> & "<div
> id=""menu" & arguments.level & """>" & objNav.name & "</div>" &
> chr(10) />
>
> <!--- check for children. If there are any, call this
> function
> recursively --->
> <cfif
> variables.reactor.createrecord("navparent").
> load(navigationid=objNav.navigationid).getnavchilditerator().
> hasmore()>
> <cfset getNav(parentID =
> objNav.navigationID, level = arguments.
> level + 1) />
> </cfif>
> </cfloop>
> <!--- loop finished --->
>
> <!--- return final variable --->
> <cfif arguments.level eq 0>
> <cfset
> arguments.event.setValue("navtext",variables.navcontainer)
> />
> </cfif>
> </cffunction>
>
</cfcomponent>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:237700
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54