@@ -4,7 +4,7 @@ use std::{
4
4
hash:: { Hash , Hasher } ,
5
5
sync:: {
6
6
atomic:: { AtomicBool , Ordering } ,
7
- Arc , Mutex , MutexGuard , OnceLock ,
7
+ Arc , Mutex , MutexGuard ,
8
8
} ,
9
9
} ;
10
10
@@ -36,7 +36,6 @@ use crate::{
36
36
/// ```
37
37
pub struct ReplaceSource < T > {
38
38
inner : Arc < T > ,
39
- inner_source_code : OnceLock < Box < str > > ,
40
39
replacements : Mutex < Vec < Replacement > > ,
41
40
/// Whether `replacements` is sorted.
42
41
is_sorted : AtomicBool ,
@@ -86,7 +85,6 @@ impl<T> ReplaceSource<T> {
86
85
pub fn new ( source : T ) -> Self {
87
86
Self {
88
87
inner : Arc :: new ( source) ,
89
- inner_source_code : OnceLock :: new ( ) ,
90
88
replacements : Mutex :: new ( Vec :: new ( ) ) ,
91
89
is_sorted : AtomicBool :: new ( true ) ,
92
90
}
@@ -113,12 +111,6 @@ impl<T> ReplaceSource<T> {
113
111
}
114
112
115
113
impl < T : Source > ReplaceSource < T > {
116
- fn get_inner_source_code ( & self ) -> & str {
117
- self
118
- . inner_source_code
119
- . get_or_init ( || Box :: from ( self . inner . source ( ) ) )
120
- }
121
-
122
114
/// Insert a content at start.
123
115
pub fn insert ( & mut self , start : u32 , content : & str , name : Option < & str > ) {
124
116
self . replace ( start, start, content, name)
@@ -177,7 +169,7 @@ impl<T: Source + Hash + PartialEq + Eq + 'static> Source for ReplaceSource<T> {
177
169
fn source ( & self ) -> Cow < str > {
178
170
self . sort_replacement ( ) ;
179
171
180
- let inner_source_code = self . get_inner_source_code ( ) ;
172
+ let inner_source_code = self . inner . source ( ) ;
181
173
182
174
// mut_string_push_str is faster that vec join
183
175
// concatenate strings benchmark, see https://github.com/hoodie/concatenation_benchmarks-rs
0 commit comments