I'm developing an API that will allow developers to post a set of parameters, which can be up to approximately 100 different ones. I'm not sure how many (or which) they will typically use, but previous experience leads me to believe that it will only be a few.
Now I'm faced with a SPEED question (since I expect many API calls per second): will it make a difference if I use switch statement versus if/elseif statements?
Because for readability purposes I would obviously prefer to do something like:
foreach ($_REQUEST as $key=>$value) {
switch ($key) {
case 'par1':
// do something
break;
case 'par2':
// do something else
break;
case 'par3':
// etc etc
My code will be a LOT more readable if I can stick to this and it will be easier to add/remove parameters without making obvious mistakes.
PS - I couldn't find a post like this on SO already, except for this one about C++
EDIT: I now found another post on SO (IF vs SWITCH) that compares a FEW statements in this context. The benchmark said there's little difference (although it's still 30%), but I'm still wondering what would happen in the case of 100 parameters.