Forum Discussion

alibaba82's avatar
alibaba82
Super Contributor
16 years ago

slow for loop - need advice

Hello,
I have a for loop that looks like this
for(int i = 1; i <= CPS_counter; i++)
{

CPS_sourceId = CPSholder.getNodeValue("//ns1:GetServiceDetailsResponse[1]/ns1:GetServiceDetailsResult[1]/ns1:ChannelLineup[1]/ns1:Channels[1]/ns1:ListingsChannel[$i]/@SourceId");
}

I notice that this loop runs fairly fast when the GetServiceDetailsResponse has relatively few items (20-30). However sometimes i get 400+ channels and the loop becomes very slow. Any ideas on a better solution.

Thanks

Ali

1 Reply

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Ali,

    What if you use something like

    def values = CPSHolder.getNodeValues( "//ns1:ListingsChannel/@SourceId");

    to get all values into a list and then use that list instead?

    regards!

    /Ole
    eviware.com