Soft'N'Design Software
/
projects
/
compress.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
74ef758
)
code comparison optimization
author
Laurent Mazet
<mazet@softndesign.org>
Mon, 16 Jan 2023 23:01:57 +0000
(
00:01
+0100)
committer
Laurent Mazet
<mazet@softndesign.org>
Mon, 16 Jan 2023 23:01:57 +0000
(
00:01
+0100)
code.c
patch
|
blob
|
blame
|
history
diff --git
a/code.c
b/code.c
index 5872443387b8048521ab189618e3ff813e8995f5..b8c8e78c7067cca3498dacda767185af1ed4fbe7 100644
(file)
--- a/
code.c
+++ b/
code.c
@@
-23,14
+23,12
@@
int codcat (char *dst, int n, char *src)
int codcmp (char *cod1, char *cod2)
{
- int i = -1;
-
- do {
- i++;
- if (cod1[i] != cod2[i]) {
- return (cod1[i] < cod2[i]) ? -1 : 1;
+ while ((*cod1 != 0) || (*cod2 != 0)) {
+ int test = *cod1++ - *cod2++;
+ if (test != 0) {
+ return (test < 0) ? -1 : 1;
}
- }
while (cod1[i] != 0);
+ }
return 0;
}