Use const_strlen in a few different places

This may slightly improve performance by allowing the compiler greater
visibility into what is happing on top of not executing at runtime in
some hot paths, but more importantly, it gets rid of magic constants in a
few different places.
This commit is contained in:
Mahmoud Al-Qudsi
2021-02-08 15:09:10 -06:00
parent 5d4c24bae1
commit cb3ab80cab
9 changed files with 32 additions and 31 deletions

View File

@@ -425,9 +425,9 @@ static char *get_interpreter(const char *command, char *buffer, size_t buff_size
close(fd);
}
if (std::strncmp(buffer, "#! /", 4) == 0) {
if (std::strncmp(buffer, "#! /", const_strlen("#! /")) == 0) {
return buffer + 3;
} else if (std::strncmp(buffer, "#!/", 3) == 0) {
} else if (std::strncmp(buffer, "#!/", const_strlen("#!/")) == 0) {
return buffer + 2;
}
return nullptr;