I have tried to use LINQ so that the second for only iterates the list of ChildNodes that match both of the if conditions that are inside the loop but have not been able to do it.Ĭan you show me how would you improve the speed of the original code focusing on an efficient way to improve the loops and nested ifs? I am not trying to determine which line of code is taking longer and the performance of the Queues is not relevant for me. Int.TryParse(clientZeroItemTchildIname.ToUpper().Replace("SERVICE", ""), out a) Īs you can see, the second for loop only takes certain items of the ChildNodes based on its name. If (clientZeroItemTchildIname.Contains("Service")) I have decided to avoid accessing Clientes and its ChildNodes.Item(t) over and over in each loop by keeping them in new variables like this: XmlNodeList clientZeroChildNodes ĬlientZeroChildNodes = Clientes.ChildNodes ĬlientZeroChildCount = clientZeroChildNodes.Count įor (int t = 0 t < clientZeroChildCount t++)ĬlientZeroItemTchildNodes = clientZeroChildNodes.Item(t).ChildNodes ĬlientZeroItemTchildCount = clientZeroItemTchildNodes.Count įor (int i = 0 i < clientZeroItemTchildCount i++)ĬlientZeroItemTchildIname = clientZeroItemTchildNodes.Item(i).Name ![]() Int.TryParse((t).ChildNodes.Item(i).Name.ToUpper().Replace("SERVICE", ""), out a) ![]() ![]() If ((t).ChildNodes.Item(i).Name.Contains("Service")) I need to optimize this code so it can execute faster, even if that means using more memory: for (int t = 0 t < t++)įor (int i = 0 i < (t).ChildNodes.Count i++)
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |