Gopala Krishna
12th January 2008, 05:42
I have usage like
foreach(Item *, items()) {
// operation a on item
// operation b on item
// operation c on item
}
Now these operations a, b, c span multiple lines and the code looks messy.
So i thought i can split them into different functions and the function can't be written in the form function(one item) instead the functions have to be of form function(ItemList)
My question is will the performance remain same even if i use it this way
(the number of items will be in hundreds and in worst case thousands)
functionA(ItemList list) {
foreach(Item *, list) {
operation
}
}
functionB(ItemList list) {
foreach(Item *, list) {
operation
}
}
functionC(ItemList list) {
foreach(Item *, list) {
operation
}
}
// --------------------and finally in the client code
functionA(list);
functionB(list);
functionC(list);
foreach(Item *, items()) {
// operation a on item
// operation b on item
// operation c on item
}
Now these operations a, b, c span multiple lines and the code looks messy.
So i thought i can split them into different functions and the function can't be written in the form function(one item) instead the functions have to be of form function(ItemList)
My question is will the performance remain same even if i use it this way
(the number of items will be in hundreds and in worst case thousands)
functionA(ItemList list) {
foreach(Item *, list) {
operation
}
}
functionB(ItemList list) {
foreach(Item *, list) {
operation
}
}
functionC(ItemList list) {
foreach(Item *, list) {
operation
}
}
// --------------------and finally in the client code
functionA(list);
functionB(list);
functionC(list);