Does anyone know if there are bugs in the duplicate() function?

I am having some trouble passing some simple but large struct arrays (e.g.
array[index]=struct[]), but the keys seem to get randomly confused, what
seems to be happening is that a date value will be randomly replaced by a
struct from another index or vice versa.

I am pointing this to the duplicate function as I have made a "deep copy"
function that does the job of duplicate() successfully, but is about 50
times slower (40-50ms vs. 2000-3000 ms). I have also used the WDDX parse
out-in method successfully, and while being faster than recursive method, it
is slow aswell.

Here is the function

        <cffunction name="deepCopy" access="private">
                <cfargument name="object" required="true">
                <cfargument name="methodType" default="WDDX">
                <cfset var returnValue="">
                <cfset var returnType="">
                <cfset var timer=getTickCount()>
                <cfset var tmp="">
                <cfif methodType IS "DUPLICATE">
                        <!--- AVERAGE TIME = 40ms --->
                        <cfset returnValue=duplicate(object)>
                        <cftrace text="deepCopy [DUPLICATE] =
#round(getTickCount()-timer)#ms"></cftrace>
                <cfelseif methodType IS "WDDX">
                        <!--- AVERAGE TIME = 1800ms --->
                        <cfwddx action="CFML2WDDX" input="#object#" 
output="tmp">
                        <cfwddx action="WDDX2CFML" input="#tmp#" 
output="returnValue">
                        <cftrace text="deepCopy [WDDX] =
#round(getTickCount()-timer)#ms"></cftrace>
                <cfelseif methodType IS "RECURSIVE">
                        <!--- AVERAGE TIME = 2400ms --->
                        <cfscript>
                        if (isSimpleValue(object)) {
                                returnValue=object;
                                returnType ="simple";
                        } else if (isStruct(object)) {
                                returnValue=structNew();
                                returnType ="struct";
                                for (i in object) {
                                        
returnValue[i]=deepCopy(object[i],methodType);
                                }
                        } else if (isArray(object)) {
                                returnValue=arrayNew(1);
                                returnType ="array";
                                for (i=1; i LTE arrayLen(object); i=i+1) {
                                        
returnValue[i]=deepCopy(object[i],methodType);
                                }
                        } else {
                                returnValue=object;
                                returnType ="other";
                        }
                        </cfscript>
                        <cftrace text="deepCopy [RECURSIVE] =
#round(getTickCount()-timer)#ms"></cftrace>
                </cfif>
                <cfreturn returnValue>
        </cffunction>

Any ideas or advice?

Thanks
Joel




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"cfaussie" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cfaussie
-~----------~----~----~----~------~----~------~--~---

Reply via email to