I'm making a text parser and I want to make a function that skips the characters [space], [newline], and [tab]. I'm expecting that these characters will occur in groups, so the function looks like this:
void skip_whitespace(int *iterator, char *text){
char c = text[*i];
while(c == ' ' || c == '\n' || c == '\t'){
while(text[*i] == ' ') *i = *i + 1;
while(text[*i] == '\n') *i = *i + 1;
while(text[*i] == '\t') *i = *i + 1;
c = text[*i]; // for next loop
}
}
This function is going to be called tens of thousands of times from inside the parser. I'm wondering if it would be better to make it a macro. I know that making it a function makes it take less space, and making it a macro makes it faster, but to what extent do both options do these things? (How much slower would a function be and how much larger would a macro be?) Thanks.