optimize strchrnul/strcspn not to scan string twice on no-match