juanthropic commented on code in PR #13424:
URL: https://github.com/apache/trafficserver/pull/13424#discussion_r4529105264


##########
plugins/header_rewrite/url_query.cc:
##########
@@ -0,0 +1,90 @@
+/*
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+*/
+#include "url_query.h"
+
+#include <algorithm>
+
+#include "swoc/MemSpan.h"
+#include "swoc/TextView.h"
+#include "swoc/Vectray.h"
+
+namespace
+{
+
+std::string_view
+param_name(std::string_view param)
+{
+  return param.substr(0, param.find('='));
+}
+
+} // namespace
+
+std::string
+sort_query(std::string_view query)
+{
+  if (query.empty()) {
+    return {};
+  }
+
+  swoc::Vectray<std::string_view, 16> params;
+  swoc::TextView                      view(query);
+
+  while (view) {
+    if (std::string_view param = view.take_prefix_at('&'); !param.empty()) {
+      params.push_back(param);
+    }
+  }
+
+  // Vectray::end() spans all N inline slots, not just the filled ones, so 
bound ranges by size().

Review Comment:
   Fixed `span()` upstream in #13808 and rebased. 7b31206de2 swaps 
`stable_sort` for `std::sort` with a position tie-break, so the sort no longer 
allocates.
   



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