Is there any problem about calling if (Serial) many times?
There is no problem, no, but yes it will slow you down.

This is the source code to the boolean operator for the Serial constructor for CDC:

Serial_::operator bool() {
    bool result = false;
    if (_usbLineInfo.lineState &gt; 0)
        result = true;
    delay(10);
    return result;
}


As you can see from that all it does is check the value of a variable.  However it also imposes a 10ms delay¹.  Personally I'd have written it as:

Serial_::operator bool() {
    return (_usbLineInfo.lineState &gt; 0);
}


And on top of that I'd have made it inline.

You might want to experiment by editing CDC.cpp to replace the bool operator with that smaller, leaner, code and see if it improves things (or breaks them completely)².

Edit: I have submitted a pull request to the Arduino GIT repository with a better method of monitoring the line state and imposing the delay(10) when it is actually needed rather than at every call to the bool operator regardless of need.


https://github.com/arduino/Arduino/pull/3624




¹ This is done to allow the port to complete opening at the PC end before data is allowed to be sent.  A better system would only perform the delay() at the moment of port opening rather than every call to the operator.

² Note that this would remove the delay which may be a bad thing as you may lose the first few bytes of the first debug message.  A better system is in the pull request mentioned in the edit to this answer.