@@ -174,34 +174,33 @@ fn serialize_resolve(resolve: &Resolve, orig: Option<&str>) -> String {
174174}
175175
176176fn 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-
182177 // If we want to try and avoid updating the lock file, parse both and
183178 // compare them; since this is somewhat expensive, don't do it in the
184179 // common case where we can update lock files.
185180 if !ws. config ( ) . lock_update_allowed ( ) {
186181 let res: CargoResult < bool > = ( || {
187- let old: resolver:: EncodableResolve = toml:: from_str ( & orig) ?;
182+ let old: resolver:: EncodableResolve = toml:: from_str ( orig) ?;
188183 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) ?)
190185 } ) ( ) ;
191186 if let Ok ( true ) = res {
192187 return true ;
193188 }
194189 }
195190
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+ }
205204 }
206205}
207206
0 commit comments