mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 16:44:33 +00:00
work on refcount
This commit is contained in:
parent
ac5eb0f6f6
commit
e9f2d9d608
5 changed files with 98 additions and 26 deletions
|
@ -490,6 +490,24 @@ pub fn dictGet(dict: RocDict, alignment: Alignment, key: Opaque, key_width: usiz
|
|||
}
|
||||
}
|
||||
|
||||
// Dict.elementsRc
|
||||
// increment or decrement all dict elements (but not the dict's allocation itself)
|
||||
pub fn elementsRc(dict: RocDict, alignment: Alignment, key_width: usize, value_width: usize, modify_key: Inc, modify_value: Inc) callconv(.C) void {
|
||||
const size = dict.dict_entries_len;
|
||||
const n = dict.dict_slot_len;
|
||||
var i: usize = 0;
|
||||
|
||||
i = 0;
|
||||
while (i < size) : (i += 1) {
|
||||
modify_key(dict.getKey(n, i, alignment, key_width, value_width));
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (i < size) : (i += 1) {
|
||||
modify_value(dict.getValue(n, i, alignment, key_width, value_width));
|
||||
}
|
||||
}
|
||||
|
||||
test "RocDict.init() contains nothing" {
|
||||
const key_size = @sizeOf(usize);
|
||||
const value_size = @sizeOf(usize);
|
||||
|
|
|
@ -13,6 +13,7 @@ comptime {
|
|||
exportDictFn(dict.dictRemove, "remove");
|
||||
exportDictFn(dict.dictContains, "contains");
|
||||
exportDictFn(dict.dictGet, "get");
|
||||
exportDictFn(dict.elementsRc, "elementsRc");
|
||||
|
||||
exportDictFn(hash.wyhash, "hash");
|
||||
exportDictFn(hash.wyhash_rocstr, "hash_str");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue