8 Replies Latest reply: Nov 16, 2007 6:42 AM by AScracker RSS

    Aviod For Loop

    AScracker Community Member
      Hi
      i am fetching the emp name and details form xml file... ther are more than 600 emp are there ,
      if am using the for loop function then the system become very slow bcoz the emp can be increaed in future...

      How to solve this Issue...

      Can any one give some idea to clear this issue

      ~~Sk
        • 1. Re: Aviod For Loop
          kglad CommunityMVP
          don't use one for-loop. break it into several for-loops that allow the stage to be updated between the various for-loops.
          • 2. Re: Aviod For Loop
            joeflashTO Community Member
            I am not too sure what you mean by "emp name." Please clarify.

            It sounds like you have some characters in an XML file that need to be reparsed, i.e. converted before the data can become usable, and you're saying that this XML parsing is slowing down your application? Unless you've got over 20,000 entries, I doubt parsing alone will introduce a significant delay, so the problem might be in your code, maybe you're attempting to use recursive functions and things are getting locked in a loop? Also, post a bit of code using the Attach Code button, and let's see what you're looking at.
            • 3. Re: Aviod For Loop
              AScracker Community Member
              Hi
              This is the structure i am using in my code..
              how could i solve this issue...

              ~~Sk
              • 4. Re: Aviod For Loop
                kglad CommunityMVP
                :

                • 5. Aviod For Loop
                  Greg Dove Community Member
                  I suspect its not the for loop that's slow. It could be the original parsing or the XPath filtering.
                  • 6. Re: Aviod For Loop
                    AScracker Community Member
                    Hi
                    Kglad ,very nice way of coding... but i am facing some problem in implemetion the code....

                    bcoz, i need to attach the code in Action Script file

                    ~~Sk
                    • 7. Aviod For Loop
                      Greg Dove Community Member
                      This part doesn't seem to make sense to me:
                      var __SeatingDetails:XML = new XML();
                      __SeatingDetails.parseXML(details);

                      I would think that all you need is :
                      __SeatingDetails=details;

                      For the timing parts.... if I were you I would double check that the problem is really with your loop by wrapping some of the key things you're doing with getTimer() checks to be certain which part is the real bottleneck.

                      Here's an example for me, using a 3 year old laptop (that badly needs replacing). It took around 17 ms to process the 700 nodes in the way that you're doing.

                      I would check
                      a) xml loadTime
                      b) xml parsing Time (optional:you could do this by using onData if you want to and then calling onLoad)
                      c) xpath.selectNodes
                      d) looping for string creation and array.push

                      • 8. Re: Aviod For Loop
                        AScracker Community Member
                        Hi

                        Kglad i'm facing some problem impleming your code to my file...

                        1) this.startInd is less than endIndex means then it moves to else function and call the forLoopFfunction
                        but it's move the else function after than it's not pass the parameter
                        forLoopF(this.startInd, this.endInd, node_xml);