File tree 2 files changed +14
-10
lines changed
2 files changed +14
-10
lines changed Original file line number Diff line number Diff line change 1
1
# Change Log
2
2
3
+ ## Unreleased
4
+
5
+ ### Changed
6
+
7
+ * ` FromStr ` implementation for ` PgLsn ` no longer allocates a ` Vec ` when splitting an lsn string on it's ` / ` .
8
+
3
9
## v0.2.6 - 2023-08-19
4
10
5
11
### Fixed
Original file line number Diff line number Diff line change @@ -33,16 +33,14 @@ impl FromStr for PgLsn {
33
33
type Err = ParseLsnError ;
34
34
35
35
fn from_str ( lsn_str : & str ) -> Result < Self , Self :: Err > {
36
- let split: Vec < & str > = lsn_str. split ( '/' ) . collect ( ) ;
37
- if split. len ( ) == 2 {
38
- let ( hi, lo) = (
39
- u64:: from_str_radix ( split[ 0 ] , 16 ) . map_err ( |_| ParseLsnError ( ( ) ) ) ?,
40
- u64:: from_str_radix ( split[ 1 ] , 16 ) . map_err ( |_| ParseLsnError ( ( ) ) ) ?,
41
- ) ;
42
- Ok ( PgLsn ( ( hi << 32 ) | lo) )
43
- } else {
44
- Err ( ParseLsnError ( ( ) ) )
45
- }
36
+ let Some ( ( split_hi, split_lo) ) = lsn_str. split_once ( '/' ) else {
37
+ return Err ( ParseLsnError ( ( ) ) ) ;
38
+ } ;
39
+ let ( hi, lo) = (
40
+ u64:: from_str_radix ( split_hi, 16 ) . map_err ( |_| ParseLsnError ( ( ) ) ) ?,
41
+ u64:: from_str_radix ( split_lo, 16 ) . map_err ( |_| ParseLsnError ( ( ) ) ) ?,
42
+ ) ;
43
+ Ok ( PgLsn ( ( hi << 32 ) | lo) )
46
44
}
47
45
}
48
46
You can’t perform that action at this time.
0 commit comments