Copilot commented on code in PR #12505:
URL: https://github.com/apache/trafficserver/pull/12505#discussion_r2363417928


##########
plugins/compress/configuration.cc:
##########
@@ -190,6 +195,15 @@ HostConfiguration::is_status_code_compressible(const 
TSHttpStatus status_code) c
   return it != compressible_status_codes_.end();
 }
 
+std::string_view
+strip_params(std::string_view v)
+{
+  swoc::TextView tv{v};
+  tv = tv.take_prefix_at(';');
+  tv.rtrim_if(static_cast<int (*)(int)>(&isspace));

Review Comment:
   The static_cast to function pointer is unnecessarily complex. Use a lambda 
or std::isspace directly for better readability: `tv.rtrim_if([](char c) { 
return std::isspace(c); })` or `tv.rtrim_if(std::isspace)`.
   ```suggestion
     tv.rtrim_if([](char c) { return std::isspace(static_cast<unsigned 
char>(c)); });
   ```



##########
plugins/compress/configuration.cc:
##########
@@ -206,8 +220,13 @@ HostConfiguration::is_content_type_compressible(const char 
*content_type, int co
     if (exclude) {
       ++match_string; // skip '!'
     }
-    if (fnmatch(match_string, scontent_type.c_str(), 0) == 0) {
-      info("compressible content type [%s], matched on pattern [%s]", 
scontent_type.c_str(), it->c_str());
+    // If content_type_ignore_parameters is set, then we match against the 
base type (without parameters) if the match string does
+    // not contain parameters. Otherwise we match against the full content 
type.
+    const std::string &target = (content_type_ignore_parameters() && 
std::strchr(match_string, ';') == nullptr) ?
+                                  
std::string(strip_params(std::string_view(scontent_type))) :
+                                  scontent_type;

Review Comment:
   Creating a temporary std::string from strip_params result is inefficient. 
Consider storing the result in a std::string variable or using string_view 
throughout to avoid unnecessary string construction.
   ```suggestion
       std::string target;
       if (content_type_ignore_parameters() && std::strchr(match_string, ';') 
== nullptr) {
         target = strip_params(std::string_view(scontent_type));
       } else {
         target = scontent_type;
       }
   ```



-- 
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