-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use smart insertion and deletion in alterF #289
base: master
Are you sure you want to change the base?
Conversation
@treeowl does this look like a good idea? If so, I can extend it to |
Sounds plausible. Please be sure to do some benchmarking. |
You have a chance to benchmark any? |
Not yet. I had a look at the existing benchmarks for |
Maybe I can simply use something like
|
Lots of things to play with. Can't be exhaustive.
…On Sun, Feb 28, 2021, 10:05 AM Simon Jakobi ***@***.***> wrote:
What would be good functors to benchmark the basic alterF and alterFEager
with?
Maybe I can simply use something like
data Pair a = Pair a a
instance Functor Pair where
fmap f (Pair a b) = Pair (f a) (f b)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#289 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAOOF7KJ2HU6N6OE2GR5WVDTBJLSRANCNFSM4PE5QE6Q>
.
|
FWIW, here's the Core diff for the current patch: --- RHS size: {terms: 65, types: 88, coercions: 0, joins: 0/3}
+-- RHS size: {terms: 79, types: 99, coercions: 0, joins: 0/2}
$walterF
= \ @ f @ k @ v w w1 w2 w3 w4 ->
case w3 of k1 { __DEFAULT ->
case w4 of m { __DEFAULT ->
case hash w1 k1 of { I# x# ->
- let { $dEq = $p1Hashable w1 } in
let { ipv = int2Word# x# } in
let {
- mv
- = case $wlookupRecordCollision# $dEq ipv k1 m of {
- (#_|#) ds1 -> Nothing;
- (#|_#) ds1 -> case ds1 of { (# a, _i #) -> Just a }
+ lookupRes
+ = case $wlookupRecordCollision# ($p1Hashable w1) ipv k1 m of {
+ (#_|#) ds1 -> Absent;
+ (#|_#) ds1 -> case ds1 of { (# a, i #) -> Present a i }
} } in
fmap
w
(\ fres ->
case fres of {
Nothing ->
- case mv of {
- Nothing -> m;
- Just x -> $wdelete' $dEq ipv k1 m
+ case lookupRes of {
+ Absent -> m;
+ Present ds dt -> $wdeleteKeyExists dt ipv k1 m
};
- Just v' -> $winsert' $dEq ipv k1 v' m
+ Just v' ->
+ case lookupRes of {
+ Absent -> $winsertNewKey ipv k1 v' m;
+ Present ds dt -> $winsertKeyExists dt ipv k1 v' m
+ }
})
- (w2 mv)
+ (w2
+ (case lookupRes of {
+ Absent -> Nothing;
+ Present x dt -> Just x
+ }))
}
}
} |
0b39809
to
497aba5
Compare
No description provided.