mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vcache: use 2x wyhash.sum64_string(hk,x).hex_full(), instead of md5.sum(hk.bytes()).hex()
This commit is contained in:
parent
5cb31c2c8f
commit
60cc8ac39c
@ -368,6 +368,20 @@ pub fn (nn byteptr) str() string {
|
|||||||
return u64(nn).hex()
|
return u64(nn).hex()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pub fn (nn byte) hex_full() string { return u64_to_hex(nn, 2) }
|
||||||
|
// pub fn (nn i8) hex_full() string { return u64_to_hex(byte(nn), 2) }
|
||||||
|
// pub fn (nn u16) hex_full() string { return u64_to_hex(nn, 4) }
|
||||||
|
// pub fn (nn i16) hex_full() string { return u64_to_hex(u16(nn), 4) }
|
||||||
|
// pub fn (nn u32) hex_full() string { return u64_to_hex(nn, 8) }
|
||||||
|
// pub fn (nn int) hex_full() string { return u64_to_hex(u32(nn), 8) }
|
||||||
|
pub fn (nn u64) hex_full() string {
|
||||||
|
return u64_to_hex(nn, 16)
|
||||||
|
}
|
||||||
|
|
||||||
|
// pub fn (nn i64) hex_full() string { return u64_to_hex(u64(nn), 16) }
|
||||||
|
// pub fn (nn any_int) hex_full() string { return u64_to_hex(nn, 16) }
|
||||||
|
// pub fn (nn voidptr) hex_full() string { return u64_to_hex(nn, 16) }
|
||||||
|
// pub fn (nn byteptr) hex_full() string { return u64_to_hex(nn, 16) }
|
||||||
pub fn (b byte) str() string {
|
pub fn (b byte) str() string {
|
||||||
// TODO
|
// TODO
|
||||||
//return int(b).str_l(7)
|
//return int(b).str_l(7)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
module pref
|
module pref
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import crypto.md5
|
import hash
|
||||||
|
|
||||||
// Using a 2 level cache, ensures a more even distribution of cache entries,
|
// Using a 2 level cache, ensures a more even distribution of cache entries,
|
||||||
// so there will not be cramped folders that contain many thousands of them.
|
// so there will not be cramped folders that contain many thousands of them.
|
||||||
@ -47,10 +47,12 @@ pub fn (mut cm CacheManager) key2cpath(key string) string {
|
|||||||
mut cpath := cm.k2cpath[key]
|
mut cpath := cm.k2cpath[key]
|
||||||
if cpath == '' {
|
if cpath == '' {
|
||||||
hk := cm.vopts + key
|
hk := cm.vopts + key
|
||||||
hash := md5.sum(hk.bytes()).hex()
|
a := hash.sum64_string(hk, 5).hex_full()
|
||||||
prefix := hash[0..2]
|
b := hash.sum64_string(hk, 7).hex_full()
|
||||||
|
khash := a + b
|
||||||
|
prefix := khash[0..2]
|
||||||
cprefix_folder := os.join_path(cm.basepath, prefix)
|
cprefix_folder := os.join_path(cm.basepath, prefix)
|
||||||
cpath = os.join_path(cprefix_folder, hash)
|
cpath = os.join_path(cprefix_folder, khash)
|
||||||
if !os.is_dir(cprefix_folder) {
|
if !os.is_dir(cprefix_folder) {
|
||||||
os.mkdir_all(cprefix_folder)
|
os.mkdir_all(cprefix_folder)
|
||||||
os.chmod(cprefix_folder, 0o777)
|
os.chmod(cprefix_folder, 0o777)
|
||||||
|
Loading…
Reference in New Issue
Block a user