@@ -13,7 +13,7 @@ use pest::Parser;
1313use regex:: Regex ;
1414use std:: collections:: HashMap ;
1515use std:: net:: { IpAddr , Ipv4Addr , Ipv6Addr } ;
16- use std:: rc :: Rc ;
16+ use std:: sync :: Arc ;
1717
1818type ParseResult < T > = Result < T , ParseError < Rule > > ;
1919
@@ -66,7 +66,7 @@ impl ATCParser {
6666 fn parse_matcher (
6767 & mut self ,
6868 source : & str ,
69- regex_cache : & mut HashMap < String , Rc < Regex > > ,
69+ regex_cache : & mut HashMap < String , Arc < Regex > > ,
7070 ) -> ParseResult < Expression > {
7171 let pairs = ATCParser :: parse ( Rule :: matcher, source) ?;
7272 let expr_pair = pairs. peek ( ) . unwrap ( ) . into_inner ( ) . peek ( ) . unwrap ( ) ;
@@ -212,7 +212,7 @@ fn parse_int_literal(pair: Pair<Rule>) -> ParseResult<i64> {
212212#[ allow( clippy:: result_large_err) ] // it's fine as parsing is not the hot path
213213fn parse_predicate (
214214 pair : Pair < Rule > ,
215- regex_cache : & mut HashMap < String , Rc < Regex > > ,
215+ regex_cache : & mut HashMap < String , Arc < Regex > > ,
216216) -> ParseResult < Predicate > {
217217 let mut pairs = pair. into_inner ( ) ;
218218 let lhs = parse_lhs ( pairs. next ( ) . unwrap ( ) ) ?;
@@ -236,7 +236,7 @@ fn parse_predicate(
236236 None => {
237237 let r = Regex :: new ( & s) . into_parse_result ( & rhs_pair) ?;
238238
239- let rc = Rc :: new ( r) ;
239+ let rc = Arc :: new ( r) ;
240240
241241 regex_cache. insert ( s, rc. clone ( ) ) ;
242242 rc
@@ -302,7 +302,7 @@ fn parse_binary_operator(pair: Pair<Rule>) -> BinaryOperator {
302302fn parse_parenthesised_expression (
303303 pair : Pair < Rule > ,
304304 pratt : & PrattParser < Rule > ,
305- regex_cache : & mut HashMap < String , Rc < Regex > > ,
305+ regex_cache : & mut HashMap < String , Arc < Regex > > ,
306306) -> ParseResult < Expression > {
307307 let mut pairs = pair. into_inner ( ) ;
308308 let pair = pairs. next ( ) . unwrap ( ) ;
@@ -321,7 +321,7 @@ fn parse_parenthesised_expression(
321321fn parse_term (
322322 pair : Pair < Rule > ,
323323 pratt : & PrattParser < Rule > ,
324- regex_cache : & mut HashMap < String , Rc < Regex > > ,
324+ regex_cache : & mut HashMap < String , Arc < Regex > > ,
325325) -> ParseResult < Expression > {
326326 let pairs = pair. into_inner ( ) ;
327327 let inner_rule = pairs. peek ( ) . unwrap ( ) ;
@@ -343,7 +343,7 @@ fn parse_term(
343343fn parse_expression (
344344 pair : Pair < Rule > ,
345345 pratt : & PrattParser < Rule > ,
346- regex_cache : & mut HashMap < String , Rc < Regex > > ,
346+ regex_cache : & mut HashMap < String , Arc < Regex > > ,
347347) -> ParseResult < Expression > {
348348 let pairs = pair. into_inner ( ) ;
349349 pratt
@@ -364,7 +364,7 @@ fn parse_expression(
364364#[ allow( clippy:: result_large_err) ] // it's fine as parsing is not the hot path
365365pub fn parse (
366366 source : & str ,
367- regex_cache : & mut HashMap < String , Rc < Regex > > ,
367+ regex_cache : & mut HashMap < String , Arc < Regex > > ,
368368) -> ParseResult < Expression > {
369369 ATCParser :: new ( ) . parse_matcher ( source, regex_cache)
370370}
0 commit comments