@@ -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
@@ -239,13 +231,6 @@ impl<T: std::fmt::Debug> std::fmt::Debug for ReplaceSource<T> {
239231 ) -> Result < ( ) , std:: fmt:: Error > {
240232 f. debug_struct ( "ReplaceSource" )
241233 . 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- )
249234 . field (
250235 "replacements" ,
251236 & self . replacements . lock ( ) . iter ( ) . take ( 3 ) . collect :: < Vec < _ > > ( ) ,
@@ -682,7 +667,6 @@ impl<T: Source> Clone for ReplaceSource<T> {
682667 fn clone ( & self ) -> Self {
683668 Self {
684669 inner : self . inner . clone ( ) ,
685- inner_source_code : self . inner_source_code . clone ( ) ,
686670 replacements : Mutex :: new ( self . replacements ( ) . clone ( ) ) ,
687671 is_sorted : AtomicBool :: new ( self . is_sorted . load ( Ordering :: SeqCst ) ) ,
688672 }
0 commit comments