@@ -174,34 +174,33 @@ fn serialize_resolve(resolve: &Resolve, orig: Option<&str>) -> String {
174
174
}
175
175
176
176
fn are_equal_lockfiles ( orig : & str , current : & str , ws : & Workspace < ' _ > ) -> bool {
177
- let mut orig = orig. to_string ( ) ;
178
- if has_crlf_line_endings ( & orig) {
179
- orig = orig. replace ( "\r \n " , "\n " ) ;
180
- }
181
-
182
177
// If we want to try and avoid updating the lock file, parse both and
183
178
// compare them; since this is somewhat expensive, don't do it in the
184
179
// common case where we can update lock files.
185
180
if !ws. config ( ) . lock_update_allowed ( ) {
186
181
let res: CargoResult < bool > = ( || {
187
- let old: resolver:: EncodableResolve = toml:: from_str ( & orig) ?;
182
+ let old: resolver:: EncodableResolve = toml:: from_str ( orig) ?;
188
183
let new: resolver:: EncodableResolve = toml:: from_str ( current) ?;
189
- Ok ( old. into_resolve ( & orig, ws) ? == new. into_resolve ( current, ws) ?)
184
+ Ok ( old. into_resolve ( orig, ws) ? == new. into_resolve ( current, ws) ?)
190
185
} ) ( ) ;
191
186
if let Ok ( true ) = res {
192
187
return true ;
193
188
}
194
189
}
195
190
196
- current == orig
197
- }
198
-
199
- fn has_crlf_line_endings ( s : & str ) -> bool {
200
- // Only check the first line.
201
- if let Some ( lf) = s. find ( '\n' ) {
202
- s[ ..lf] . ends_with ( '\r' )
203
- } else {
204
- false
191
+ let mut orig_iter = orig. lines ( ) ;
192
+ let mut current_iter = current. lines ( ) ;
193
+ loop {
194
+ match ( orig_iter. next ( ) , current_iter. next ( ) ) {
195
+ ( Some ( o) , Some ( c) ) => {
196
+ if o != c {
197
+ return false ;
198
+ }
199
+ }
200
+ ( Some ( _) , None ) => return false ,
201
+ ( None , Some ( _) ) => return false ,
202
+ ( None , None ) => return true ,
203
+ }
205
204
}
206
205
}
207
206
0 commit comments