File tree Expand file tree Collapse file tree 1 file changed +9
-15
lines changed
Expand file tree Collapse file tree 1 file changed +9
-15
lines changed Original file line number Diff line number Diff line change @@ -341,26 +341,20 @@ impl JsString {
341341 // which means it is safe to read the `refcount` as `read_only` here.
342342 unsafe {
343343 let h = h. as_ptr ( ) ;
344- if ( * h) . refcount . read_only == 0 {
344+ let tagged_len = ( * h) . tagged_len ;
345+ let len = tagged_len. len ( ) ;
346+ let is_latin1 = tagged_len. is_latin1 ( ) ;
347+ let ptr = if ( * h) . refcount . read_only == 0 {
345348 let h = h. cast :: < StaticJsString > ( ) ;
346- return if ( * h) . tagged_len . is_latin1 ( ) {
347- JsStr :: latin1 ( std:: slice:: from_raw_parts (
348- ( * h) . ptr ,
349- ( * h) . tagged_len . len ( ) ,
350- ) )
349+ ( * h) . ptr
351350 } else {
352- JsStr :: utf16 ( std:: slice:: from_raw_parts (
353- ( * h) . ptr . cast ( ) ,
354- ( * h) . tagged_len . len ( ) ,
355- ) )
351+ ( & raw const ( * h) . data ) . cast :: < u8 > ( )
356352 } ;
357- }
358353
359- let len = ( * h) . len ( ) ;
360- if ( * h) . is_latin1 ( ) {
361- JsStr :: latin1 ( std:: slice:: from_raw_parts ( addr_of ! ( ( * h) . data) . cast ( ) , len) )
354+ if is_latin1 {
355+ JsStr :: latin1 ( std:: slice:: from_raw_parts ( ptr, len) )
362356 } else {
363- JsStr :: utf16 ( std:: slice:: from_raw_parts ( addr_of ! ( ( * h ) . data ) . cast ( ) , len) )
357+ JsStr :: utf16 ( std:: slice:: from_raw_parts ( ptr . cast :: < u16 > ( ) , len) )
364358 }
365359 }
366360 }
You can’t perform that action at this time.
0 commit comments