From d0ae22e4b794606ef99dc124b8b40a93cc24f9ba Mon Sep 17 00:00:00 2001 From: johnvg Date: Tue, 19 Apr 2011 11:37:59 +0000 Subject: use unique array select and update instead of replace git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@1930 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d --- frontend/containers.icl | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'frontend/containers.icl') diff --git a/frontend/containers.icl b/frontend/containers.icl index 6b1cd08..2b2bd8b 100644 --- a/frontend/containers.icl +++ b/frontend/containers.icl @@ -387,14 +387,11 @@ ikhInsert :: !Bool !IntKey a !*(IntKeyHashtable a) -> (!Bool, !.IntKeyHashtable ikhInsert overide int_key value (IntKeyHashtable ikh_rehash_threshold ikh_nr_of_entries ikh_bitmask ikh_entries) | ikh_rehash_threshold<=ikh_nr_of_entries = ikhInsert overide int_key value (grow ikh_entries) - #! hash_value - = int_key bitand ikh_bitmask - (tree, ikh_entries) - = replace ikh_entries hash_value IKT_Leaf + #! hash_value = int_key bitand ikh_bitmask + (tree, ikh_entries) = ikh_entries![hash_value] (is_new, tree) = iktUInsert overide int_key value tree - ikh_entries - = { ikh_entries & [hash_value] = tree } + ikh_entries = { ikh_entries & [hash_value] = tree } | is_new = (is_new, (IntKeyHashtable ikh_rehash_threshold (ikh_nr_of_entries+1) ikh_bitmask ikh_entries)) = (is_new, (IntKeyHashtable ikh_rehash_threshold ikh_nr_of_entries ikh_bitmask ikh_entries)) @@ -444,14 +441,11 @@ ikhUSearch :: !IntKey !*(IntKeyHashtable a) -> (!.Optional a, !*IntKeyHashtable ikhUSearch int_key (IntKeyHashtable ikh_rehash_threshold ikh_nr_of_entries ikh_bitmask ikh_entries) | size ikh_entries==0 = (No, IntKeyHashtable ikh_rehash_threshold ikh_nr_of_entries ikh_bitmask ikh_entries) - # hash_value - = int_key bitand ikh_bitmask - (ikt, ikh_entries) - = replace ikh_entries hash_value IKT_Leaf + # hash_value = int_key bitand ikh_bitmask + (ikt, ikh_entries) = ikh_entries![hash_value] (opt_result, ikt) = iktUSearch int_key ikt - ikh_entries - = { ikh_entries & [hash_value] = ikt } + ikh_entries = { ikh_entries & [hash_value] = ikt } = (opt_result, (IntKeyHashtable ikh_rehash_threshold ikh_nr_of_entries ikh_bitmask ikh_entries)) iktUInsert :: !Bool !IntKey a !*(IntKeyTree a) -> (!Bool, !.IntKeyTree a) -- cgit v1.2.3