OSDN Git Service

Cppcheck: Either the condition '....empty()' is redundant or content is accessed...
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 6 Jan 2019 11:04:30 +0000 (20:04 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 6 Jan 2019 11:04:30 +0000 (20:04 +0900)
Src/LineFiltersList.cpp
Src/codepage_detect.cpp

index 1588d89..859ffa4 100644 (file)
@@ -224,12 +224,12 @@ void LineFiltersList::SaveFilters()
  */
 void LineFiltersList::Import(const String& filters)
 {
-       const TCHAR sep[] = _T("\r\n");
-       TCHAR *p_filters = (TCHAR *)&filters[0];
-       TCHAR *pfilterNext = nullptr;
-       
        if (!filters.empty())
        {
+               const TCHAR sep[] = _T("\r\n");
+               TCHAR *p_filters = (TCHAR *)&filters[0];
+               TCHAR *pfilterNext = nullptr;
+       
                // find each regular expression and add to list
                TCHAR *token = _tcstok_s(p_filters, sep, &pfilterNext);
                while (token != nullptr)
index d844392..2f9c90e 100644 (file)
@@ -86,9 +86,9 @@ static unsigned demoGuessEncoding_html(const char *src, size_t len, int defcodep
                if (!http_equiv.empty() && _stricmp(http_equiv.c_str(), "content-type") == 0)
                {
                        std::string content(markdown.GetAttribute("content"));
-                       char *pchKey = &content[0];
                        if (!content.empty())
                        {
+                               char *pchKey = &content[0];
                                while (size_t cchKey = strcspn(pchKey += strspn(pchKey, "; \t\r\n"), ";="))
                                {
                                        char *pchValue = pchKey + cchKey;