Skip to content
Snippets Groups Projects
Commit cfc1014c authored by Alex Lyon's avatar Alex Lyon
Browse files

string: fix a couple minor issues in strncmp()

parent 50f79e9a
No related branches found
No related tags found
1 merge request!56string: address performance concerns for strncmp()
......@@ -161,7 +161,7 @@ pub unsafe extern "C" fn strncmp(s1: *const c_char, s2: *const c_char, n: usize)
for (&a, &b) in s1.iter().zip(s2.iter()) {
let val = (a as c_int) - (b as c_int);
if val != 0 || a == 0 {
if a != b || a == 0 {
return val;
}
}
......
......@@ -9,7 +9,5 @@ int main(int argc, char* argv[]) {
printf("%d\n", strncmp("a", "c", 1));
printf("%d\n", strncmp("a", "a", 2));
puts("test");
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment