I want to optimise my code, and for that, I want to iterate parallely through Maps.
My current code is:
for (String orderKey: insertMap.keySet()) {
if(orderKey.contains('#New')) {
//Do big stuff: (500 lines)
}
}
for (String orderKey: updateMap.keySet()) {
if(orderKey.contains('#New')) {
//Do same big stuff as above: (500 lines)
}
}
EDIT: Adding the types of Map
Map<String,CustomObject> insertMap,updateMap = new Map<String,CustomObject>();
Now, as you can see, then inner IF condition is same, only the values of the orderKeyare coming from different maps.
The values of the orderKey will be different from each Map. They won't ever be the same.
Is there a way to combine these FOR Loops in one?
Maybe like :
for((String orderKey : insertMap.keySet()) OR (String orderKey : udpateMap.keySet()))
{
if(orderKey.contains('#New')) {
//Do big stuff
}
}
I know the above code is not possible, I just wanted to show what I am looking for.
The number of lines that I have masked by the //Do Big Stuff are almost 500. And hence I want to reduce the lines of code.
Thanks a lot !
Do big stuffrun once or twice for the values in each of those maps?