From 364e98c92d6e4c15b67b6c66256810f2f98b412a Mon Sep 17 00:00:00 2001 From: Vaclav Brozek Date: Tue, 2 Mar 2021 18:59:31 +0100 Subject: [PATCH] Optimize calls to find*() for a single char. The character literal overload is more efficient. --- examples/ThirdPartyLibs/cpp_base64/base64.cpp | 2 +- examples/TinyRenderer/model.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/ThirdPartyLibs/cpp_base64/base64.cpp b/examples/ThirdPartyLibs/cpp_base64/base64.cpp index 40b555c44..b0c002783 100644 --- a/examples/ThirdPartyLibs/cpp_base64/base64.cpp +++ b/examples/ThirdPartyLibs/cpp_base64/base64.cpp @@ -136,7 +136,7 @@ std::string base64_decode(std::string const& encoded_string, bool remove_linebre std::string copy(encoded_string); size_t pos=0; - while ((pos = copy.find("\n", pos)) != std::string::npos) { + while ((pos = copy.find('\n', pos)) != std::string::npos) { copy.erase(pos, 1); } diff --git a/examples/TinyRenderer/model.cpp b/examples/TinyRenderer/model.cpp index 1f5bebc1b..d0a009130 100644 --- a/examples/TinyRenderer/model.cpp +++ b/examples/TinyRenderer/model.cpp @@ -149,7 +149,7 @@ Vec3f Model::vert(int iface, int nthvert) void Model::load_texture(std::string filename, const char *suffix, TGAImage &img) { std::string texfile(filename); - size_t dot = texfile.find_last_of("."); + size_t dot = texfile.find_last_of('.'); if (dot != std::string::npos) { texfile = texfile.substr(0, dot) + std::string(suffix);