Skip to content

Commit fef86b0

Browse files
committed
map: Use simpler fnv-1a hash function
1 parent 8120240 commit fef86b0

File tree

17 files changed

+10
-190
lines changed

17 files changed

+10
-190
lines changed

Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ SRC=\
3333
pp.c\
3434
scan.c\
3535
scope.c\
36-
siphash.c\
3736
stmt.c\
3837
targ.c\
3938
token.c\
@@ -59,7 +58,6 @@ $(objdir)/pp.o : pp.c util.h cc.h $(stagedeps) ; $(CC) $(CFLAGS)
5958
$(objdir)/qbe.o : qbe.c util.h cc.h ops.h $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ qbe.c
6059
$(objdir)/scan.o : scan.c util.h cc.h $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ scan.c
6160
$(objdir)/scope.o : scope.c util.h cc.h $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ scope.c
62-
$(objdir)/siphash.o : siphash.c $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ siphash.c
6361
$(objdir)/stmt.o : stmt.c util.h cc.h $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ stmt.c
6462
$(objdir)/targ.o : targ.c util.h cc.h $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ targ.c
6563
$(objdir)/token.o : token.c util.h cc.h $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ token.c

attr.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include <limits.h>
22
#include <stdbool.h>
3-
#include <stdint.h>
43
#include <string.h>
54
#include "util.h"
65
#include "cc.h"

decl.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include <limits.h>
33
#include <stdbool.h>
44
#include <stddef.h>
5-
#include <stdint.h>
65
#include <stdio.h>
76
#include <stdlib.h>
87
#include <string.h>

eval.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <limits.h>
22
#include <stdbool.h>
33
#include <stddef.h>
4-
#include <stdint.h>
54
#include "util.h"
65
#include "cc.h"
76

init.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include <assert.h>
22
#include <stdbool.h>
3-
#include <stdint.h>
43
#include <stdlib.h>
54
#include <string.h>
65
#include "util.h"

main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include <stdbool.h>
2-
#include <stdint.h>
32
#include <stdio.h>
43
#include <stdlib.h>
54
#include "util.h"

map.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
#include <assert.h>
22
#include <stdbool.h>
3-
#include <stdint.h>
43
#include <stdlib.h>
54
#include <string.h>
65
#include "util.h"
76

8-
static uint64_t
7+
static unsigned long
98
hash(const void *ptr, size_t len)
109
{
11-
extern int siphash(const uint8_t *, const size_t, const uint8_t *, uint8_t *, const size_t);
12-
static const uint8_t k[16] = {0}; /* XXX: we don't have a way to get entropy in standard C */
13-
uint64_t r;
14-
15-
siphash(ptr, len, k, (uint8_t *)&r, sizeof(r));
16-
17-
return r;
10+
unsigned long h;
11+
const unsigned char *pos, *end;
12+
13+
/* FNV-1a */
14+
h = 0x811c9dc5;
15+
for (pos = ptr, end = pos + len; pos != end; ++pos)
16+
h = (h ^ *pos) * 0x1000193;
17+
return h;
1818
}
1919

2020
void

pp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <assert.h>
22
#include <stdarg.h>
33
#include <stdbool.h>
4-
#include <stdint.h>
54
#include <stdio.h>
65
#include <stdlib.h>
76
#include <string.h>

scan.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <ctype.h>
22
#include <stdarg.h>
33
#include <stdbool.h>
4-
#include <stdint.h>
54
#include <stdio.h>
65
#include <stdlib.h>
76
#include <string.h>

scope.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include <stdbool.h>
22
#include <stdlib.h>
3-
#include <stdint.h>
43
#include <string.h>
54
#include "util.h"
65
#include "cc.h"

0 commit comments

Comments
 (0)