File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ use core::fmt;
24
24
#[ cfg( feature = "std" ) ]
25
25
use std:: rc:: Rc ;
26
26
#[ cfg( feature = "std" ) ]
27
- use std:: sync :: atomic :: { AtomicUsize , Ordering } ;
27
+ use std:: cell :: Cell ;
28
28
29
29
use log:: debug;
30
30
#[ cfg( feature = "std" ) ]
@@ -62,11 +62,12 @@ macro_rules! return_ok_if_some {
62
62
macro_rules! check_recursion_depth {
63
63
( $this: ident) => {
64
64
let remaining_depth = $this. remaining_depth. clone( ) ;
65
- if remaining_depth. fetch_sub( 1 , Ordering :: SeqCst ) <= 0 {
65
+ remaining_depth. set( remaining_depth. get( ) . saturating_sub( 1 ) ) ;
66
+ if remaining_depth. get( ) == 0 {
66
67
return Err ( ParserError :: RecursionLimitExceeded ) ;
67
68
}
68
69
defer! {
69
- remaining_depth. fetch_add ( 1 , Ordering :: SeqCst ) ;
70
+ remaining_depth. set ( remaining_depth . get ( ) + 1 ) ;
70
71
}
71
72
} ;
72
73
}
@@ -136,7 +137,7 @@ pub struct Parser<'a> {
136
137
index : usize ,
137
138
dialect : & ' a dyn Dialect ,
138
139
#[ cfg( feature = "std" ) ]
139
- remaining_depth : Rc < AtomicUsize > ,
140
+ remaining_depth : Rc < Cell < usize > > ,
140
141
}
141
142
142
143
impl < ' a > Parser < ' a > {
@@ -147,7 +148,7 @@ impl<'a> Parser<'a> {
147
148
index : 0 ,
148
149
dialect,
149
150
#[ cfg( feature = "std" ) ]
150
- remaining_depth : Rc :: new ( AtomicUsize :: new ( 96 ) ) ,
151
+ remaining_depth : Rc :: new ( Cell :: new ( 96 ) ) ,
151
152
}
152
153
}
153
154
You can’t perform that action at this time.
0 commit comments