ams-tschoening commented on a change in pull request #75:
URL: https://github.com/apache/logging-log4cxx/pull/75#discussion_r757029168



##########
File path: src/main/cpp/locationinfo.cpp
##########
@@ -35,6 +41,21 @@ const LocationInfo& LocationInfo::getLocationUnavailable()
        return unavailable;
 }
 
+/**
+ * filter short file name
+ * @param fileName
+ * @return shortFileName
+ */
+const std::string filterFileName(const char* const fileName){
+       std::string fullFileName(fileName);
+       std::size_t found = fullFileName.rfind(SHORT_FILENAME_SPLIT_CHAR);
+       if (found != std::string::npos) {
+               return fullFileName.substr(found + 1);
+       } else {
+               return std::string(fileName);
+       }

Review comment:
       If C++17 is an option, 
[basic_string_view::rfind](https://en.cppreference.com/w/cpp/string/basic_string_view/rfind)
 could be used. Avoiding `std::string::rfind` doesn't seem that important to 
me, but if so, the search should be backwards. Something like the following:
   
   ```cpp
   size_t len = strlen(fileName);
   
   for (size_t pos = std::max(len - 1, 0); pos >= 0; --pos)
   {
     if (fileName[pos] == SHORT_FILENAME_SPLIT_CHAR)
     {
       return fileName[pos + 1];
     }
   
     if (pos == 0)
     {
       return fileName;
     }
   }
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to