Use smart insertion and deletion in alterF#289
Draft
sjakobi wants to merge 1 commit into
Draft
Conversation
Member
Author
|
@treeowl does this look like a good idea? If so, I can extend it to |
Collaborator
|
Sounds plausible. Please be sure to do some benchmarking. |
Collaborator
|
You have a chance to benchmark any? |
Member
Author
Not yet. I had a look at the existing benchmarks for |
Member
Author
Maybe I can simply use something like |
Collaborator
|
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>
.
|
Member
Author
|
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.