mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 14:36:36 +08:00
Optimize calls to std::string::find() and friends for a single char.
The character literal overload is more efficient. More info at: http://clang.llvm.org/extra/clang-tidy/checks/performance-faster-string-find.html
This commit is contained in:
parent
d159417474
commit
8391a23600
@ -189,7 +189,7 @@ TEST(Core_OutputArrayCreate, _13772)
|
||||
TEST(Core_String, find_last_of__with__empty_string)
|
||||
{
|
||||
cv::String s;
|
||||
size_t p = s.find_last_of("q", 0);
|
||||
size_t p = s.find_last_of('q', 0);
|
||||
// npos is not exported: EXPECT_EQ(cv::String::npos, p);
|
||||
EXPECT_EQ(std::string::npos, p);
|
||||
}
|
||||
|
@ -620,7 +620,7 @@ namespace cv {
|
||||
// read section
|
||||
read_net = false;
|
||||
++layers_counter;
|
||||
const size_t layer_type_size = line.find("]") - 1;
|
||||
const size_t layer_type_size = line.find(']') - 1;
|
||||
CV_Assert(layer_type_size < line.size());
|
||||
std::string layer_type = line.substr(1, layer_type_size);
|
||||
net->layers_cfg[layers_counter]["layer_type"] = layer_type;
|
||||
|
@ -389,7 +389,7 @@ Pin parsePin(const std::string &name)
|
||||
{
|
||||
Pin pin(name);
|
||||
|
||||
size_t delimiter_pos = name.find_first_of(":");
|
||||
size_t delimiter_pos = name.find_first_of(':');
|
||||
if (delimiter_pos != std::string::npos)
|
||||
{
|
||||
pin.name = name.substr(0, delimiter_pos);
|
||||
|
Loading…
Reference in New Issue
Block a user