Skip to content

Commit 593823e

Browse files
authored
Integrate fixes from PR#91. (#126)
This PR has been in review for a while and now there are a bunch of conflicts and it's a branch in a fork repo so I cannot edit the branch directly.
1 parent 29b4dd7 commit 593823e

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

cache_test.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/dgraph-io/ristretto/z"
1111
)
1212

13-
var wait time.Duration = time.Millisecond * 10
13+
var wait = time.Millisecond * 10
1414

1515
func TestCacheKeyToHash(t *testing.T) {
1616
keyToHashCount := 0
@@ -305,10 +305,8 @@ func TestCacheSet(t *testing.T) {
305305
if val, ok := c.Get(1); val == nil || val.(int) != 1 || !ok {
306306
t.Fatal("set/get returned wrong value")
307307
}
308-
} else {
309-
if val, ok := c.Get(1); val != nil || ok {
310-
t.Fatal("set was dropped but value still added")
311-
}
308+
} else if val, ok := c.Get(1); val != nil || ok {
309+
t.Fatal("set was dropped but value still added")
312310
}
313311
c.Set(1, 2, 2)
314312
val, ok := c.store.Get(z.KeyToHash(1))

policy.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ func (p *tinyLFU) Push(keys []uint64) {
335335
func (p *tinyLFU) Estimate(key uint64) int64 {
336336
hits := p.freq.Estimate(key)
337337
if p.door.Has(key) {
338-
hits += 1
338+
hits++
339339
}
340340
return hits
341341
}

z/rtutil_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ func SipHash(p []byte) (l, h uint64) {
5353

5454
// Compression.
5555
for len(p) >= 8 {
56-
5756
m := uint64(p[0]) | uint64(p[1])<<8 | uint64(p[2])<<16 | uint64(p[3])<<24 |
5857
uint64(p[4])<<32 | uint64(p[5])<<40 | uint64(p[6])<<48 | uint64(p[7])<<56
5958

@@ -252,8 +251,8 @@ func SipHash(p []byte) (l, h uint64) {
252251
h = hash >> 1
253252
l = hash << 1 >> 1
254253
return l, h
255-
256254
}
255+
257256
func BenchmarkNanoTime(b *testing.B) {
258257
for i := 0; i < b.N; i++ {
259258
NanoTime()

0 commit comments

Comments
 (0)