@@ -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
@@ -239,13 +231,6 @@ impl<T: std::fmt::Debug> std::fmt::Debug for ReplaceSource<T> {
239
231
) -> Result < ( ) , std:: fmt:: Error > {
240
232
f. debug_struct ( "ReplaceSource" )
241
233
. field ( "inner" , self . inner . as_ref ( ) )
242
- . field (
243
- "inner_source_code" ,
244
- & self
245
- . inner_source_code
246
- . get ( )
247
- . map ( |s| s. chars ( ) . take ( 50 ) . collect :: < String > ( ) ) ,
248
- )
249
234
. field (
250
235
"replacements" ,
251
236
& self . replacements . lock ( ) . iter ( ) . take ( 3 ) . collect :: < Vec < _ > > ( ) ,
@@ -682,7 +667,6 @@ impl<T: Source> Clone for ReplaceSource<T> {
682
667
fn clone ( & self ) -> Self {
683
668
Self {
684
669
inner : self . inner . clone ( ) ,
685
- inner_source_code : self . inner_source_code . clone ( ) ,
686
670
replacements : Mutex :: new ( self . replacements ( ) . clone ( ) ) ,
687
671
is_sorted : AtomicBool :: new ( self . is_sorted . load ( Ordering :: SeqCst ) ) ,
688
672
}
0 commit comments