File tree Expand file tree Collapse file tree 1 file changed +2
-9
lines changed Expand file tree Collapse file tree 1 file changed +2
-9
lines changed Original file line number Diff line number Diff line change @@ -12,10 +12,6 @@ use std::str;
12
12
use std:: sync:: Mutex ;
13
13
use std:: sync:: OnceLock ;
14
14
15
- fn leak ( s : String ) -> & ' static str {
16
- Box :: leak ( s. into_boxed_str ( ) )
17
- }
18
-
19
15
static STRING_CACHE : OnceLock < Mutex < HashSet < & ' static str > > > = OnceLock :: new ( ) ;
20
16
21
17
#[ derive( Clone , Copy ) ]
@@ -63,12 +59,9 @@ impl Eq for InternedString {}
63
59
64
60
impl InternedString {
65
61
pub fn new ( str : & str ) -> InternedString {
66
- let mut cache = STRING_CACHE
67
- . get_or_init ( || Default :: default ( ) )
68
- . lock ( )
69
- . unwrap ( ) ;
62
+ let mut cache = STRING_CACHE . get_or_init ( Default :: default) . lock ( ) . unwrap ( ) ;
70
63
let s = cache. get ( str) . cloned ( ) . unwrap_or_else ( || {
71
- let s = leak ( str. to_string ( ) ) ;
64
+ let s = str. to_string ( ) . leak ( ) ;
72
65
cache. insert ( s) ;
73
66
s
74
67
} ) ;
You can’t perform that action at this time.
0 commit comments