1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

rand: use time microseconds too in default rand initialization; generate proper uuid_v4

This commit is contained in:
Delyan Angelov
2020-07-24 14:28:27 +03:00
parent c429fa7e27
commit 289974dd15
4 changed files with 17 additions and 5 deletions

View File

@ -25,7 +25,8 @@ fn nr_next(prev u32) u32 {
// time_seed_array is a utility function that returns the required number of u32s generated from system time
[inline]
pub fn time_seed_array(count int) []u32 {
mut seed := u32(time.now().unix_time())
ctime := time.now()
mut seed := u32(ctime.unix_time() ^ ctime.microsecond)
mut seed_data := []u32{cap: count}
for _ in 0 .. count {
seed = nr_next(seed)