File tree Expand file tree Collapse file tree 5 files changed +22
-24
lines changed Expand file tree Collapse file tree 5 files changed +22
-24
lines changed Original file line number Diff line number Diff line change 1
1
use bstr:: { BString , ByteSlice } ;
2
- use byteyarn:: Yarn ;
2
+ use byteyarn:: YarnBox ;
3
3
use gix_glob:: Pattern ;
4
4
5
5
use crate :: {
@@ -59,7 +59,7 @@ impl Outcome {
59
59
self . selected . clear ( ) ;
60
60
self . selected . extend ( attribute_names. map ( |name| {
61
61
(
62
- Yarn :: inlined ( name) . unwrap_or_else ( || name . to_string ( ) . into_boxed_str ( ) . into ( ) ) ,
62
+ YarnBox :: new ( name) . immortalize ( ) ,
63
63
collection. name_to_meta . get ( name) . map ( |meta| meta. id ) ,
64
64
)
65
65
} ) ) ;
@@ -315,7 +315,7 @@ impl MetadataCollection {
315
315
None => {
316
316
let order = AttributeId ( self . name_to_meta . len ( ) ) ;
317
317
self . name_to_meta . insert (
318
- Yarn :: inlined ( name) . unwrap_or_else ( || name . to_string ( ) . into_boxed_str ( ) . into ( ) ) ,
318
+ YarnBox :: new ( name) . immortalize ( ) ,
319
319
Metadata {
320
320
id : order,
321
321
macro_attributes : Default :: default ( ) ,
@@ -335,10 +335,7 @@ impl MetadataCollection {
335
335
Some ( meta) => meta. id ,
336
336
None => {
337
337
let order = AttributeId ( self . name_to_meta . len ( ) ) ;
338
- self . name_to_meta . insert (
339
- Yarn :: inlined ( name) . unwrap_or_else ( || name. to_string ( ) . into_boxed_str ( ) . into ( ) ) ,
340
- order. into ( ) ,
341
- ) ;
338
+ self . name_to_meta . insert ( YarnBox :: new ( name) . immortalize ( ) , order. into ( ) ) ;
342
339
order
343
340
}
344
341
}
Original file line number Diff line number Diff line change 1
1
use bstr:: { BStr , ByteSlice } ;
2
- use byteyarn:: { ByteYarn , YarnRef } ;
2
+ use byteyarn:: { ByteYarn , YarnBox , YarnRef } ;
3
3
4
4
use crate :: { State , StateRef } ;
5
5
@@ -49,10 +49,7 @@ impl<'a> From<ValueRef<'a>> for Value {
49
49
50
50
impl From < & str > for Value {
51
51
fn from ( v : & str ) -> Self {
52
- Value (
53
- ByteYarn :: inlined ( v. as_bytes ( ) )
54
- . unwrap_or_else ( || ByteYarn :: from_boxed_bytes ( v. as_bytes ( ) . to_vec ( ) . into_boxed_slice ( ) ) ) ,
55
- )
52
+ Value ( YarnBox :: new ( v) . immortalize ( ) . into ( ) )
56
53
}
57
54
}
58
55
Original file line number Diff line number Diff line change @@ -85,7 +85,9 @@ pub(crate) fn find_scheme(input: &BStr) -> InputScheme {
85
85
pub ( crate ) fn url ( input : & BStr , protocol_end : usize ) -> Result < crate :: Url , Error > {
86
86
const MAX_LEN : usize = 1024 ;
87
87
let bytes_to_path = input[ protocol_end + "://" . len ( ) ..]
88
- . find ( b"/" )
88
+ . iter ( )
89
+ . skip_while ( |b| * * b == b'/' )
90
+ . position ( |b| * b == b'/' )
89
91
. unwrap_or ( input. len ( ) - protocol_end) ;
90
92
if bytes_to_path > MAX_LEN {
91
93
return Err ( Error :: TooLong {
Original file line number Diff line number Diff line change @@ -139,15 +139,17 @@ mod unknown {
139
139
140
140
#[ test]
141
141
fn fuzzed ( ) {
142
- let base = Path :: new ( "tests" ) . join ( "fixtures" ) . join ( "fuzzed" ) ;
143
- let location = base. join ( Path :: new ( "very-long" ) . with_extension ( "url" ) ) ;
144
- let url = std:: fs:: read ( & location) . unwrap ( ) ;
145
- let start = std:: time:: Instant :: now ( ) ;
146
- gix_url:: parse ( url. as_bstr ( ) ) . ok ( ) ;
147
- assert ! (
148
- start. elapsed( ) < Duration :: from_millis( 100 ) ,
149
- "URL at '{}' parsed too slowly, took {:.00}s" ,
150
- location. display( ) ,
151
- start. elapsed( ) . as_secs_f32( )
152
- )
142
+ for name in [ "very-long" , "very-long2" ] {
143
+ let base = Path :: new ( "tests" ) . join ( "fixtures" ) . join ( "fuzzed" ) ;
144
+ let location = base. join ( Path :: new ( name) . with_extension ( "url" ) ) ;
145
+ let url = std:: fs:: read ( & location) . unwrap ( ) ;
146
+ let start = std:: time:: Instant :: now ( ) ;
147
+ gix_url:: parse ( url. as_bstr ( ) ) . ok ( ) ;
148
+ assert ! (
149
+ start. elapsed( ) < Duration :: from_millis( 100 ) ,
150
+ "URL at '{}' parsed too slowly, took {:.00}s" ,
151
+ location. display( ) ,
152
+ start. elapsed( ) . as_secs_f32( )
153
+ )
154
+ }
153
155
}
You can’t perform that action at this time.
0 commit comments