File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -257,12 +257,18 @@ impl Drop for Identifier {
257
257
}
258
258
}
259
259
260
+ impl Identifier {
261
+ pub ( crate ) fn ptr_eq ( & self , rhs : & Self ) -> bool {
262
+ self . head == rhs. head && self . tail == rhs. tail
263
+ }
264
+ }
265
+
260
266
impl PartialEq for Identifier {
261
267
fn eq ( & self , rhs : & Self ) -> bool {
262
- if self . is_empty_or_inline ( ) {
268
+ if self . ptr_eq ( rhs ) {
263
269
// Fast path (most common)
264
- self . head == rhs . head && self . tail == rhs . tail
265
- } else if rhs. is_empty_or_inline ( ) {
270
+ true
271
+ } else if self . is_empty_or_inline ( ) || rhs. is_empty_or_inline ( ) {
266
272
false
267
273
} else {
268
274
// SAFETY: both reprs are in the heap allocated representation.
Original file line number Diff line number Diff line change @@ -50,8 +50,10 @@ impl PartialOrd for BuildMetadata {
50
50
51
51
impl Ord for Prerelease {
52
52
fn cmp ( & self , rhs : & Self ) -> Ordering {
53
+ if self . identifier . ptr_eq ( & rhs. identifier ) {
54
+ return Ordering :: Equal ;
55
+ }
53
56
match self . is_empty ( ) {
54
- true if rhs. is_empty ( ) => return Ordering :: Equal ,
55
57
// A real release compares greater than prerelease.
56
58
true => return Ordering :: Greater ,
57
59
// Prerelease compares less than the real release.
@@ -105,6 +107,9 @@ impl Ord for Prerelease {
105
107
106
108
impl Ord for BuildMetadata {
107
109
fn cmp ( & self , rhs : & Self ) -> Ordering {
110
+ if self . identifier . ptr_eq ( & rhs. identifier ) {
111
+ return Ordering :: Equal ;
112
+ }
108
113
let lhs = self . as_str ( ) . split ( '.' ) ;
109
114
let mut rhs = rhs. as_str ( ) . split ( '.' ) ;
110
115
You can’t perform that action at this time.
0 commit comments