﻿# V817\. It is more efficient to search for 'X' character rather than a string\.

The analyzer detected a function that looks for a character in a string and can be optimized\.

Consider the following example of inefficient code:

```cpp
bool isSharpPresent(const std::string& str)
{
  return str.find("#") != std::string::npos;
}
```

In this code, it is better to use an overridden version of the `find` function that receives a character instead of a string\.

Optimized code:

```cpp
bool isSharpPresent(const std::string& str)
{
  return str.find('#') != std::string::npos;
}
```

The following example also uses inefficient code that can be optimized:

```cpp
const char* GetSharpSubStr(const char* str)
{
  return strstr(str, "#");
}
```

In this code, it is better to use the `strchr` function to search for a character instead of a string:

```cpp
const char* GetSharpSubStr(const char* str)
{
  return strchr(str, '#');
}
```