mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
rand: tag with @[direct_array_access]
some frequently used functions, that are already debugged (#22523)
This commit is contained in:
parent
4c55de5e65
commit
49513afd51
1 changed files with 6 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
||||||
module rand
|
module rand
|
||||||
|
|
||||||
const clock_seq_hi_and_reserved_valid_values = [`8`, `9`, `a`, `b`]
|
const clock_seq_hi_and_reserved_valid_values = [`8`, `9`, `a`, `b`]!
|
||||||
|
|
||||||
// uuid_v4 generates a random (v4) UUID
|
// uuid_v4 generates a random (v4) UUID
|
||||||
// See https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random)
|
// See https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random)
|
||||||
|
@ -8,6 +8,7 @@ pub fn uuid_v4() string {
|
||||||
return internal_uuid_v4(mut default_rng)
|
return internal_uuid_v4(mut default_rng)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@[direct_array_access]
|
||||||
fn internal_uuid_v4(mut rng PRNG) string {
|
fn internal_uuid_v4(mut rng PRNG) string {
|
||||||
buflen := 36
|
buflen := 36
|
||||||
mut buf := unsafe { malloc_noscan(37) }
|
mut buf := unsafe { malloc_noscan(37) }
|
||||||
|
@ -56,6 +57,7 @@ fn internal_uuid_v4(mut rng PRNG) string {
|
||||||
|
|
||||||
const ulid_encoding = '0123456789ABCDEFGHJKMNPQRSTVWXYZ'
|
const ulid_encoding = '0123456789ABCDEFGHJKMNPQRSTVWXYZ'
|
||||||
|
|
||||||
|
@[direct_array_access]
|
||||||
fn internal_ulid_at_millisecond(mut rng PRNG, unix_time_milli u64) string {
|
fn internal_ulid_at_millisecond(mut rng PRNG, unix_time_milli u64) string {
|
||||||
buflen := 26
|
buflen := 26
|
||||||
mut buf := unsafe { malloc_noscan(27) }
|
mut buf := unsafe { malloc_noscan(27) }
|
||||||
|
@ -136,6 +138,7 @@ fn init() {
|
||||||
at_exit(deinit) or {}
|
at_exit(deinit) or {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@[direct_array_access]
|
||||||
fn read_32(mut rng PRNG, mut buf []u8) {
|
fn read_32(mut rng PRNG, mut buf []u8) {
|
||||||
p32 := unsafe { &u32(buf.data) }
|
p32 := unsafe { &u32(buf.data) }
|
||||||
u32s := buf.len / 4
|
u32s := buf.len / 4
|
||||||
|
@ -149,6 +152,7 @@ fn read_32(mut rng PRNG, mut buf []u8) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@[direct_array_access]
|
||||||
fn read_64(mut rng PRNG, mut buf []u8) {
|
fn read_64(mut rng PRNG, mut buf []u8) {
|
||||||
p64 := unsafe { &u64(buf.data) }
|
p64 := unsafe { &u64(buf.data) }
|
||||||
u64s := buf.len / 8
|
u64s := buf.len / 8
|
||||||
|
@ -162,6 +166,7 @@ fn read_64(mut rng PRNG, mut buf []u8) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@[direct_array_access]
|
||||||
fn read_internal(mut rng PRNG, mut buf []u8) {
|
fn read_internal(mut rng PRNG, mut buf []u8) {
|
||||||
match rng.block_size() {
|
match rng.block_size() {
|
||||||
32 {
|
32 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue