@@ -484,19 +484,6 @@ pin_project! {
484
484
impl wrpc_transport:: Index < Self > for Outgoing {
485
485
#[ instrument( level = "trace" , skip( self ) ) ]
486
486
fn index ( & self , path : & [ usize ] ) -> anyhow:: Result < Self > {
487
- ensure ! ( !path. is_empty( ) ) ;
488
- let mut header = BytesMut :: with_capacity ( path. len ( ) . saturating_add ( 5 ) ) ;
489
- let depth = path. len ( ) ;
490
- let n = u32:: try_from ( depth)
491
- . map_err ( |err| std:: io:: Error :: new ( std:: io:: ErrorKind :: InvalidInput , err) ) ?;
492
- trace ! ( n, "encoding path length" ) ;
493
- Leb128Encoder . encode ( n, & mut header) ?;
494
- for p in path {
495
- let p = u32:: try_from ( * p)
496
- . map_err ( |err| std:: io:: Error :: new ( std:: io:: ErrorKind :: InvalidInput , err) ) ?;
497
- trace ! ( p, "encoding path element" ) ;
498
- Leb128Encoder . encode ( p, & mut header) ?;
499
- }
500
487
match self {
501
488
Self :: Opening {
502
489
path : base,
@@ -509,12 +496,33 @@ impl wrpc_transport::Index<Self> for Outgoing {
509
496
conn,
510
497
io,
511
498
..
512
- } => Ok ( Self :: Opening {
513
- header : header. freeze ( ) ,
514
- path : Arc :: from ( [ base, path] . concat ( ) ) ,
515
- conn : conn. clone ( ) ,
516
- io : Arc :: clone ( io) ,
517
- } ) ,
499
+ } => {
500
+ ensure ! ( !path. is_empty( ) ) ;
501
+ let path: Arc < [ usize ] > = if base. is_empty ( ) {
502
+ Arc :: from ( path)
503
+ } else {
504
+ Arc :: from ( [ base. as_ref ( ) , path] . concat ( ) )
505
+ } ;
506
+ let mut header = BytesMut :: with_capacity ( path. len ( ) . saturating_add ( 5 ) ) ;
507
+ let depth = path. len ( ) ;
508
+ let n = u32:: try_from ( depth)
509
+ . map_err ( |err| std:: io:: Error :: new ( std:: io:: ErrorKind :: InvalidInput , err) ) ?;
510
+ trace ! ( n, "encoding path length" ) ;
511
+ Leb128Encoder . encode ( n, & mut header) ?;
512
+ for p in path. as_ref ( ) {
513
+ let p = u32:: try_from ( * p) . map_err ( |err| {
514
+ std:: io:: Error :: new ( std:: io:: ErrorKind :: InvalidInput , err)
515
+ } ) ?;
516
+ trace ! ( p, "encoding path element" ) ;
517
+ Leb128Encoder . encode ( p, & mut header) ?;
518
+ }
519
+ Ok ( Self :: Opening {
520
+ header : header. freeze ( ) ,
521
+ path,
522
+ conn : conn. clone ( ) ,
523
+ io : Arc :: clone ( io) ,
524
+ } )
525
+ }
518
526
}
519
527
}
520
528
}
0 commit comments