This is an automated email from the ASF dual-hosted git repository.

mochen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new a0a93162a6 Use single regex match in RecLookupMatchingRecords (#12584)
a0a93162a6 is described below

commit a0a93162a61f4ec38369661fa5bb5ef5bf5109aa
Author: Mo Chen <[email protected]>
AuthorDate: Mon Oct 20 17:27:10 2025 -0500

    Use single regex match in RecLookupMatchingRecords (#12584)
    
    This use case only requires matching a single regex.  DFA is meant for 
matching multiple regexes.
---
 src/records/RecCore.cc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/records/RecCore.cc b/src/records/RecCore.cc
index a150f6bd75..9aab580928 100644
--- a/src/records/RecCore.cc
+++ b/src/records/RecCore.cc
@@ -556,8 +556,8 @@ RecErrT
 RecLookupMatchingRecords(unsigned rec_type, const char *match, void 
(*callback)(const RecRecord *, void *), void *data,
                          bool /* lock ATS_UNUSED */)
 {
-  int num_records;
-  DFA regex;
+  int   num_records;
+  Regex regex;
 
   if (!regex.compile(match, RE_CASE_INSENSITIVE | RE_UNANCHORED)) {
     return REC_ERR_FAIL;
@@ -571,7 +571,7 @@ RecLookupMatchingRecords(unsigned rec_type, const char 
*match, void (*callback)(
     tmp.rec_type = RECT_PROCESS;
 
     for (auto &&[name, type, val] : ts::Metrics::instance()) {
-      if (regex.match(name.data()) >= 0) {
+      if (regex.exec(name.data())) {
         tmp.name         = name.data();
         tmp.data_type    = type == ts::Metrics::MetricType::COUNTER ? 
RECD_COUNTER : RECD_INT;
         tmp.data.rec_int = val;
@@ -589,7 +589,7 @@ RecLookupMatchingRecords(unsigned rec_type, const char 
*match, void (*callback)(
       continue;
     }
 
-    if (regex.match(r->name) < 0) {
+    if (!regex.exec(r->name)) {
       continue;
     }
 

Reply via email to