Skip to content

Commit bb53ff5

Browse files
authored
crypto.blake2b,crypto.blake2s: add @[direct_array_access] to hot functions (#25750)
1 parent bc333ab commit bb53ff5

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

vlib/crypto/blake2b/blake2b_block_generic.v

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module blake2b
1111
import math.bits
1212

1313
// mixing function g
14-
@[inline]
14+
@[direct_array_access; inline]
1515
fn g(mut v []u64, a u8, b u8, c u8, d u8, x u64, y u64) {
1616
v[a] = v[a] + v[b] + x
1717
v[d] = bits.rotate_left_64((v[d] ^ v[a]), nr1)
@@ -24,7 +24,7 @@ fn g(mut v []u64, a u8, b u8, c u8, d u8, x u64, y u64) {
2424
}
2525

2626
// one complete mixing round with the function g
27-
@[inline]
27+
@[direct_array_access; inline]
2828
fn (d Digest) mixing_round(mut v []u64, s []u8) {
2929
g(mut v, 0, 4, 8, 12, d.m[s[0]], d.m[s[1]])
3030
g(mut v, 1, 5, 9, 13, d.m[s[2]], d.m[s[3]])
@@ -38,6 +38,7 @@ fn (d Digest) mixing_round(mut v []u64, s []u8) {
3838
}
3939

4040
// compression function f
41+
@[direct_array_access]
4142
fn (mut d Digest) f(f bool) {
4243
// initialize the working vector
4344
mut v := []u64{len: 0, cap: 16}

vlib/crypto/blake2s/blake2s_block_generic.v

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module blake2s
1111
import math.bits
1212

1313
// mixing function g
14-
@[inline]
14+
@[direct_array_access; inline]
1515
fn g(mut v []u32, a u8, b u8, c u8, d u8, x u32, y u32) {
1616
v[a] = v[a] + v[b] + x
1717
v[d] = bits.rotate_left_32((v[d] ^ v[a]), nr1)
@@ -24,7 +24,7 @@ fn g(mut v []u32, a u8, b u8, c u8, d u8, x u32, y u32) {
2424
}
2525

2626
// one complete mixing round with the function g
27-
@[inline]
27+
@[direct_array_access; inline]
2828
fn (d Digest) mixing_round(mut v []u32, s []u8) {
2929
g(mut v, 0, 4, 8, 12, d.m[s[0]], d.m[s[1]])
3030
g(mut v, 1, 5, 9, 13, d.m[s[2]], d.m[s[3]])
@@ -38,6 +38,7 @@ fn (d Digest) mixing_round(mut v []u32, s []u8) {
3838
}
3939

4040
// compression function f
41+
@[direct_array_access]
4142
fn (mut d Digest) f(f bool) {
4243
// initialize the working vector
4344
mut v := []u32{len: 0, cap: 16}

0 commit comments

Comments
 (0)