diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-08-04 16:15:53 +0200 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-08-04 16:15:53 +0200 |
commit | 8c34c4cbb3780c433148966a004f5a51aace0f64 (patch) | |
tree | a590de76c326f6dfe3c92d2e27b78ce2ab792289 /src/index.go | |
parent | 22c83f4b8d98b6b3c7dabc078e70801d0201876c (diff) |
First set of code review patches
Diffstat (limited to 'src/index.go')
-rw-r--r-- | src/index.go | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/index.go b/src/index.go index 44b4974..e518b0f 100644 --- a/src/index.go +++ b/src/index.go @@ -3,6 +3,7 @@ package main import ( "crypto/rand" "sync" + "unsafe" ) /* Index=0 is reserved for unset indecies @@ -23,14 +24,7 @@ type IndexTable struct { func randUint32() (uint32, error) { var buff [4]byte _, err := rand.Read(buff[:]) - id := uint32(buff[0]) - id <<= 8 - id |= uint32(buff[1]) - id <<= 8 - id |= uint32(buff[2]) - id <<= 8 - id |= uint32(buff[3]) - return id, err + return *((*uint32)(unsafe.Pointer(&buff))), err } func (table *IndexTable) Init() { |