We don’t have a hashCode function now or really a good way of using object references.  Can you file this issue at http://www.macromedia.com/go/wish?

 


From: [email protected] [mailto:[email protected]] On Behalf Of Sean McKibben
Sent: Thursday, May 12, 2005 10:37 AM
To: [email protected]
Subject: [flexcoders] XMLObjectOutput bug

 

I think that the trObj method of XMLObjectOutput.as has as problem 
where it keeps doubling the size of its internal __stack variable 
with each new object it has.
The section which has:
         // verify that we have not already seen this object
         if(obj instanceof Array || obj instanceof Function || obj 
instanceof MovieClip || obj instanceof Object)
         {
             var len = __stack.length;
             // walk the stack and look for matches
             for(var i = 0; i < len; i++)
             {
                 if(obj == this  || __stack[i] == obj)
                 {
                     // we have a match, get out
                     var nSpace = "      " + spacer;
                     trace(spacer + " [self reference - will not 
trace]");
                     return;
                 } else {
                     // not found, add it to the list
                     __stack.push(obj);
                 }
             }
         }

seems like it would add the object to the stack each time it iterates 
through the for loop unless the particular object it is searching for 
happens to be the one it is testing in that iteration. This seems to 
be the cause of the problem where the __stack array grows 
geometrically in size.
If you're using this to trace objects with any depth, __stack.length 
very quickly gets up in to the thousands, self reference or not.

Changing that section of code to:
         // verify that we have not already seen this object
         if(obj instanceof Array || obj instanceof Function || obj 
instanceof MovieClip || obj instanceof Object)
         {
             var len = __stack.length;
             // walk the stack and look for matches
             for(var i = 0; i < len; i++)
             {
                 if(obj == this  || __stack[i] == obj)
                 {
                     // we have a match, get out
                     var nSpace = "      " + spacer;
                     trace(spacer + " [self reference - will not 
trace]");
                     return;
                 }
             }
             // not found, add it to the list
             __stack.push(obj);
         }
seems to do the trick, although I wonder if there is a way to do this 
with hash tables instead of iterating through a numbered array?

Is there a way of generating hash codes or using an object reference 
as a key?

Sean McKibben
[EMAIL PROTECTED]




Yahoo! Groups Links

Reply via email to