@@ -4,7 +4,7 @@ use std::{
44 hash:: { Hash , Hasher } ,
55 sync:: {
66 atomic:: { AtomicBool , Ordering } ,
7- Arc , Mutex , MutexGuard , OnceLock ,
7+ Arc , Mutex , MutexGuard ,
88 } ,
99} ;
1010
@@ -36,7 +36,6 @@ use crate::{
3636/// ```
3737pub struct ReplaceSource < T > {
3838 inner : Arc < T > ,
39- inner_source_code : OnceLock < Box < str > > ,
4039 replacements : Mutex < Vec < Replacement > > ,
4140 /// Whether `replacements` is sorted.
4241 is_sorted : AtomicBool ,
@@ -86,7 +85,6 @@ impl<T> ReplaceSource<T> {
8685 pub fn new ( source : T ) -> Self {
8786 Self {
8887 inner : Arc :: new ( source) ,
89- inner_source_code : OnceLock :: new ( ) ,
9088 replacements : Mutex :: new ( Vec :: new ( ) ) ,
9189 is_sorted : AtomicBool :: new ( true ) ,
9290 }
@@ -113,12 +111,6 @@ impl<T> ReplaceSource<T> {
113111}
114112
115113impl < 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-
122114 /// Insert a content at start.
123115 pub fn insert ( & mut self , start : u32 , content : & str , name : Option < & str > ) {
124116 self . replace ( start, start, content, name)
@@ -177,7 +169,7 @@ impl<T: Source + Hash + PartialEq + Eq + 'static> Source for ReplaceSource<T> {
177169 fn source ( & self ) -> Cow < str > {
178170 self . sort_replacement ( ) ;
179171
180- let inner_source_code = self . get_inner_source_code ( ) ;
172+ let inner_source_code = self . inner . source ( ) ;
181173
182174 // mut_string_push_str is faster that vec join
183175 // concatenate strings benchmark, see https://github.com/hoodie/concatenation_benchmarks-rs
0 commit comments