Improve performance a bit by removing strlen(str) > 0.