@@ -18,33 +18,39 @@ unsafe impl Sync for Buffer {}
1818unsafe impl Send for Buffer { }
1919
2020impl Default for Buffer {
21+ #[ inline]
2122 fn default ( ) -> Self {
2223 Self :: from ( vec ! [ ] )
2324 }
2425}
2526
2627impl Deref for Buffer {
2728 type Target = [ u8 ] ;
29+ #[ inline]
2830 fn deref ( & self ) -> & [ u8 ] {
2931 unsafe { slice:: from_raw_parts ( self . data as * const u8 , self . len ) }
3032 }
3133}
3234
3335impl DerefMut for Buffer {
36+ #[ inline]
3437 fn deref_mut ( & mut self ) -> & mut [ u8 ] {
3538 unsafe { slice:: from_raw_parts_mut ( self . data , self . len ) }
3639 }
3740}
3841
3942impl Buffer {
43+ #[ inline]
4044 pub ( super ) fn new ( ) -> Self {
4145 Self :: default ( )
4246 }
4347
48+ #[ inline]
4449 pub ( super ) fn clear ( & mut self ) {
4550 self . len = 0 ;
4651 }
4752
53+ #[ inline]
4854 pub ( super ) fn take ( & mut self ) -> Self {
4955 mem:: take ( self )
5056 }
@@ -53,6 +59,7 @@ impl Buffer {
5359 // because in the case of small arrays, codegen can be more efficient
5460 // (avoiding a memmove call). With extend_from_slice, LLVM at least
5561 // currently is not able to make that optimization.
62+ #[ inline]
5663 pub ( super ) fn extend_from_array < const N : usize > ( & mut self , xs : & [ u8 ; N ] ) {
5764 if xs. len ( ) > ( self . capacity - self . len ) {
5865 let b = self . take ( ) ;
@@ -64,6 +71,7 @@ impl Buffer {
6471 }
6572 }
6673
74+ #[ inline]
6775 pub ( super ) fn extend_from_slice ( & mut self , xs : & [ u8 ] ) {
6876 if xs. len ( ) > ( self . capacity - self . len ) {
6977 let b = self . take ( ) ;
@@ -75,6 +83,7 @@ impl Buffer {
7583 }
7684 }
7785
86+ #[ inline]
7887 pub ( super ) fn push ( & mut self , v : u8 ) {
7988 // The code here is taken from Vec::push, and we know that reserve()
8089 // will panic if we're exceeding isize::MAX bytes and so there's no need
@@ -91,22 +100,26 @@ impl Buffer {
91100}
92101
93102impl Write for Buffer {
103+ #[ inline]
94104 fn write ( & mut self , xs : & [ u8 ] ) -> io:: Result < usize > {
95105 self . extend_from_slice ( xs) ;
96106 Ok ( xs. len ( ) )
97107 }
98108
109+ #[ inline]
99110 fn write_all ( & mut self , xs : & [ u8 ] ) -> io:: Result < ( ) > {
100111 self . extend_from_slice ( xs) ;
101112 Ok ( ( ) )
102113 }
103114
115+ #[ inline]
104116 fn flush ( & mut self ) -> io:: Result < ( ) > {
105117 Ok ( ( ) )
106118 }
107119}
108120
109121impl Drop for Buffer {
122+ #[ inline]
110123 fn drop ( & mut self ) {
111124 let b = self . take ( ) ;
112125 ( b. drop ) ( b) ;
0 commit comments