[git commit master] diff: defeat gcc's optimization
Denys Vlasenko
vda.linux at googlemail.com
Mon Jan 18 04:22:34 UTC 2010
commit: http://git.busybox.net/busybox/commit/?id=032bf6553346537cb02d0406c05548c8aa23c81f
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
editors/diff.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/editors/diff.c b/editors/diff.c
index af6917a..b89bbc1 100644
--- a/editors/diff.c
+++ b/editors/diff.c
@@ -435,7 +435,10 @@ static int *create_J(FILE_and_pos_t ft[2], int nlen[2], off_t *ix[2])
tok = read_token(&ft[i], tok);
if (!(tok & TOK_EMPTY)) {
/* Hash algorithm taken from Robert Sedgewick, Algorithms in C, 3d ed., p 578. */
- hash = hash * 128 - hash + TOK2CHAR(tok);
+ /*hash = hash * 128 - hash + TOK2CHAR(tok);
+ * gcc insists on optimizing above to "hash * 127 + ...", thus... */
+ unsigned o = hash - TOK2CHAR(tok);
+ hash = hash * 128 - o; /* we want SPEED here */
continue;
}
if (nlen[i]++ == sz) {
--
1.6.3.3
More information about the busybox-cvs
mailing list