@@ -95,7 +95,15 @@ impl Uniq {
9595
9696 self . build_meta ( & next_buf, & mut next_meta) ;
9797
98- if self . keys_differ ( & current_buf, & current_meta, & next_buf, & next_meta) {
98+ if self . keys_are_equal ( & current_buf, & current_meta, & next_buf, & next_meta) {
99+ if self . all_repeated {
100+ self . print_line ( writer, & current_buf, group_count, first_line_printed) ?;
101+ first_line_printed = true ;
102+ std:: mem:: swap ( & mut current_buf, & mut next_buf) ;
103+ std:: mem:: swap ( & mut current_meta, & mut next_meta) ;
104+ }
105+ group_count += 1 ;
106+ } else {
99107 if ( group_count == 1 && !self . repeats_only )
100108 || ( group_count > 1 && !self . uniques_only )
101109 {
@@ -105,14 +113,6 @@ impl Uniq {
105113 std:: mem:: swap ( & mut current_buf, & mut next_buf) ;
106114 std:: mem:: swap ( & mut current_meta, & mut next_meta) ;
107115 group_count = 1 ;
108- } else {
109- if self . all_repeated {
110- self . print_line ( writer, & current_buf, group_count, first_line_printed) ?;
111- first_line_printed = true ;
112- std:: mem:: swap ( & mut current_buf, & mut next_buf) ;
113- std:: mem:: swap ( & mut current_meta, & mut next_meta) ;
114- }
115- group_count += 1 ;
116116 }
117117 next_buf. clear ( ) ;
118118 }
@@ -136,7 +136,7 @@ impl Uniq {
136136 if self . zero_terminated { 0 } else { b'\n' }
137137 }
138138
139- fn keys_differ (
139+ fn keys_are_equal (
140140 & self ,
141141 first_line : & [ u8 ] ,
142142 first_meta : & LineMeta ,
@@ -146,11 +146,11 @@ impl Uniq {
146146 let first_slice = & first_line[ first_meta. key_start ..first_meta. key_end ] ;
147147 let second_slice = & second_line[ second_meta. key_start ..second_meta. key_end ] ;
148148
149- if !self . ignore_case {
150- return first_slice != second_slice;
149+ if self . ignore_case {
150+ first_slice. eq_ignore_ascii_case ( second_slice)
151+ } else {
152+ first_slice == second_slice
151153 }
152-
153- !first_slice. eq_ignore_ascii_case ( second_slice)
154154 }
155155
156156 fn key_bounds ( & self , line : & [ u8 ] ) -> ( usize , usize ) {
0 commit comments