Files
bun.sh/src/identity_context.zig
Dylan Conway 745b6b94ee Store workspace package versions (#6258)
* Store workspace package versions in the lockfile

* more logging

* wip

* keep information from workspace name array and cache

* hash key

* remove cache, compare workspaces with initially loaded

* uncomment sort

* remove comments

* remove allocation

* package json

* test `bun add <package>` without workspace prefix

* Update test/cli/install/bun-install.test.ts

Co-authored-by: Markus Staab <maggus.staab@googlemail.com>

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Markus Staab <maggus.staab@googlemail.com>
2023-10-03 02:17:21 -07:00

34 lines
1019 B
Zig

pub fn IdentityContext(comptime Key: type) type {
return struct {
pub fn hash(_: @This(), key: Key) u64 {
return key;
}
pub fn eql(_: @This(), a: Key, b: Key) bool {
return a == b;
}
};
}
/// When storing hashes as keys in a hash table, we don't want to hash the hashes or else we increase the chance of collisions. This is also marginally faster since it means hashing less stuff.
/// `ArrayIdentityContext` and `IdentityContext` are distinct because ArrayHashMap expects u32 hashes but HashMap expects u64 hashes.
pub const ArrayIdentityContext = struct {
pub fn hash(_: @This(), key: u32) u32 {
return key;
}
pub fn eql(_: @This(), a: u32, b: u32, _: usize) bool {
return a == b;
}
pub const U64 = struct {
pub fn hash(_: @This(), key: u64) u32 {
return @truncate(key);
}
pub fn eql(_: @This(), a: u64, b: u64, _: usize) bool {
return a == b;
}
};
};