diff options
author | Max Kellermann <max@duempel.org> | 2013-10-14 22:00:21 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-10-14 22:00:21 +0200 |
commit | 6fd481df978ad4666780ef838e6c8540f6ea190f (patch) | |
tree | e437903388be90df8a92c58c05af8f4f51c7e8e1 /src | |
parent | b915e433911b4597626c721a8ae4a6e9dae6ac5a (diff) |
Mapper, ...: use memcmp() instead of strncmp() where appropriate
Micro-optimization.
Diffstat (limited to 'src')
-rw-r--r-- | src/Mapper.cxx | 2 | ||||
-rw-r--r-- | src/OtherCommands.cxx | 2 | ||||
-rw-r--r-- | src/QueueCommands.cxx | 4 | ||||
-rw-r--r-- | src/input/CurlInputPlugin.cxx | 4 | ||||
-rw-r--r-- | src/output/HttpdClient.cxx | 4 | ||||
-rw-r--r-- | src/playlist/SoundCloudPlaylistPlugin.cxx | 2 | ||||
-rw-r--r-- | src/util/UriUtil.cxx | 4 |
7 files changed, 11 insertions, 11 deletions
diff --git a/src/Mapper.cxx b/src/Mapper.cxx index 7c89ba7c4..c1e508b05 100644 --- a/src/Mapper.cxx +++ b/src/Mapper.cxx @@ -252,7 +252,7 @@ std::string map_fs_to_utf8(const char *path_fs) { if (!music_dir_fs.IsNull() && - strncmp(path_fs, music_dir_fs.c_str(), music_dir_fs_length) == 0 && + memcmp(path_fs, music_dir_fs.data(), music_dir_fs_length) == 0 && G_IS_DIR_SEPARATOR(path_fs[music_dir_fs_length])) /* remove musicDir prefix */ path_fs += music_dir_fs_length + 1; diff --git a/src/OtherCommands.cxx b/src/OtherCommands.cxx index 52899d184..f60078cf9 100644 --- a/src/OtherCommands.cxx +++ b/src/OtherCommands.cxx @@ -114,7 +114,7 @@ handle_lsinfo(Client *client, int argc, char *argv[]) /* default is root directory */ uri = ""; - if (strncmp(uri, "file:///", 8) == 0) { + if (memcmp(uri, "file:///", 8) == 0) { /* print information about an arbitrary local file */ const char *path_utf8 = uri + 7; const Path path_fs = Path::FromUTF8(path_utf8); diff --git a/src/QueueCommands.cxx b/src/QueueCommands.cxx index a70a5f250..0bb984364 100644 --- a/src/QueueCommands.cxx +++ b/src/QueueCommands.cxx @@ -43,7 +43,7 @@ handle_add(Client *client, gcc_unused int argc, char *argv[]) char *uri = argv[1]; enum playlist_result result; - if (strncmp(uri, "file:///", 8) == 0) { + if (memcmp(uri, "file:///", 8) == 0) { const char *path_utf8 = uri + 7; const Path path_fs = Path::FromUTF8(path_utf8); @@ -86,7 +86,7 @@ handle_addid(Client *client, int argc, char *argv[]) unsigned added_id; enum playlist_result result; - if (strncmp(uri, "file:///", 8) == 0) { + if (memcmp(uri, "file:///", 8) == 0) { const char *path_utf8 = uri + 7; const Path path_fs = Path::FromUTF8(path_utf8); diff --git a/src/input/CurlInputPlugin.cxx b/src/input/CurlInputPlugin.cxx index b707da2f0..d972ff3a7 100644 --- a/src/input/CurlInputPlugin.cxx +++ b/src/input/CurlInputPlugin.cxx @@ -1084,8 +1084,8 @@ static struct input_stream * input_curl_open(const char *url, Mutex &mutex, Cond &cond, Error &error) { - if ((strncmp(url, "http://", 7) != 0) && - (strncmp(url, "https://", 8) != 0)) + if (memcmp(url, "http://", 7) != 0 && + memcmp(url, "https://", 8) != 0) return NULL; struct input_curl *c = new input_curl(url, mutex, cond); diff --git a/src/output/HttpdClient.cxx b/src/output/HttpdClient.cxx index f7ae8d10c..5b65cc956 100644 --- a/src/output/HttpdClient.cxx +++ b/src/output/HttpdClient.cxx @@ -78,7 +78,7 @@ HttpdClient::HandleLine(const char *line) assert(state != RESPONSE); if (state == REQUEST) { - if (strncmp(line, "GET /", 5) != 0) { + if (memcmp(line, "GET /", 5) != 0) { /* only GET is supported */ LogWarning(httpd_output_domain, "malformed request line from client"); @@ -86,7 +86,7 @@ HttpdClient::HandleLine(const char *line) } line = strchr(line + 5, ' '); - if (line == nullptr || strncmp(line + 1, "HTTP/", 5) != 0) { + if (line == nullptr || memcmp(line + 1, "HTTP/", 5) != 0) { /* HTTP/0.9 without request headers */ BeginResponse(); return true; diff --git a/src/playlist/SoundCloudPlaylistPlugin.cxx b/src/playlist/SoundCloudPlaylistPlugin.cxx index 99bef29e7..ee256f31f 100644 --- a/src/playlist/SoundCloudPlaylistPlugin.cxx +++ b/src/playlist/SoundCloudPlaylistPlugin.cxx @@ -175,7 +175,7 @@ static int handle_mapkey(void *ctx, const unsigned char* stringval, data->key = Other; for (i = 0; i < Other; ++i) { - if (strncmp((const char *)stringval, key_str[i], stringlen) == 0) { + if (memcmp((const char *)stringval, key_str[i], stringlen) == 0) { data->key = i; break; } diff --git a/src/util/UriUtil.cxx b/src/util/UriUtil.cxx index 4b0cec11b..a326530e0 100644 --- a/src/util/UriUtil.cxx +++ b/src/util/UriUtil.cxx @@ -86,9 +86,9 @@ uri_remove_auth(const char *uri) const char *auth, *slash, *at; char *p; - if (strncmp(uri, "http://", 7) == 0) + if (memcmp(uri, "http://", 7) == 0) auth = uri + 7; - else if (strncmp(uri, "https://", 8) == 0) + else if (memcmp(uri, "https://", 8) == 0) auth = uri + 8; else /* unrecognized URI */ |