Skip to content

Commit 7b4fadd

Browse files
authored
Merge pull request moonbitlang#441 from yj-qin/hex-literal
Use hex literals in xxhash and ryu
2 parents 037fae2 + 7e59b06 commit 7b4fadd

3 files changed

Lines changed: 16 additions & 16 deletions

File tree

bytes/xxhash.mbt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515
// https://github.com/Cyan4973/xxHash/blob/dev/doc/xxhash_spec.md#xxh32-algorithm-description
1616

17-
let gPRIME1 = -1640531535
17+
let gPRIME1 = 0x9E3779B1
1818

19-
let gPRIME2 = -2048144777
19+
let gPRIME2 = 0x85EBCA77
2020

21-
let gPRIME3 = -1028477379
21+
let gPRIME3 = 0xC2B2AE3D
2222

23-
let gPRIME4 = 668265263
23+
let gPRIME4 = 0x27D4EB2F
2424

25-
let gPRIME5 = 374761393
25+
let gPRIME5 = 0x165667B1
2626

2727
fn xxhash32(input : Bytes, seed : Int) -> Int {
2828
let len = input.length()

double/ryu.mbt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ let gDOUBLE_POW5_INV_SPLIT2 : Array[Int64] = [
161161
]
162162

163163
let gPOW5_INV_OFFSETS : Array[Int] = [
164-
1414808916, 67458373, 268701696, 4195348, 1073807360, 1091917141, 1108, 65604,
165-
1073741824, 1140850753, 1346716752, 1431634004, 1365595476, 1073758208, 16777217,
166-
66816, 1364284433, 89478484, 0,
164+
0x54544554, 0x04055545, 0x10041000, 0x00400414, 0x40010000, 0x41155555, 0x00000454,
165+
0x00010044, 0x40000000, 0x44000041, 0x50454450, 0x55550054, 0x51655554, 0x40004000,
166+
0x01000001, 0x00010500, 0x51515411, 0x05555554, 0x00000000,
167167
]
168168

169169
let gDOUBLE_POW5_SPLIT2 : Array[Int64] = [
@@ -176,9 +176,9 @@ let gDOUBLE_POW5_SPLIT2 : Array[Int64] = [
176176
]
177177

178178
let gPOW5_OFFSETS : Array[Int] = [
179-
0, 0, 0, 0, 1073741824, 1500076437, 1431590229, 1448432917, 1091896580, 1079333904,
180-
1146442053, 1146111296, 1163220304, 1073758208, -1773927360, 1431721317, 1413824581,
181-
1075134801, 1431671125, 1363170645, 261,
179+
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x40000000, 0x59695995, 0x55545555,
180+
0x56555515, 0x41150504, 0x40555410, 0x44555145, 0x44504540, 0x45555550, 0x40004000,
181+
0x96440440, 0x55565565, 0x54454045, 0x40154151, 0x55559155, 0x51405555, 0x00000105,
182182
]
183183

184184
let gDOUBLE_POW5_TABLE : Array[Int64] = [

int64/xxhash.mbt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
// limitations under the License.
1414

1515
// Not needed for 8 bytes data
16-
// let gPRIME1 = -1640531535
16+
// let gPRIME1 = 0x9E3779B1
1717

18-
let gPRIME2 = -2048144777
18+
let gPRIME2 = 0x85EBCA77
1919

20-
let gPRIME3 = -1028477379
20+
let gPRIME3 = 0xC2B2AE3D
2121

22-
let gPRIME4 = 668265263
22+
let gPRIME4 = 0x27D4EB2F
2323

24-
let gPRIME5 = 374761393
24+
let gPRIME5 = 0x165667B1
2525

2626
// https://github.com/Cyan4973/xxHash/blob/dev/doc/xxhash_spec.md#xxh32-algorithm-description
2727
// For a more readable version, see bytes/xxhash.mbt

0 commit comments

Comments
 (0)