diff options
author | joe <joe@jerkface.net> | 2014-05-10 19:53:49 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2014-05-10 19:53:49 -0400 |
commit | 840d37a6dcab32e8dec673945cf3e4f5c99815b5 (patch) | |
tree | 4fc8730ae2c847b4453a3fbf04e832a8367e13bc /KeyRing.hs | |
parent | bb5dbf01160084e4639583221a4c084f96e8c06e (diff) |
reorganized mergeSig
Diffstat (limited to 'KeyRing.hs')
-rw-r--r-- | KeyRing.hs | 34 |
1 files changed, 16 insertions, 18 deletions
@@ -2853,25 +2853,23 @@ merge_ db filename qs = foldl mergeit db (zip [0..] qs) | |||
2853 | then sigs++[first (asMapped n) sig] | 2853 | then sigs++[first (asMapped n) sig] |
2854 | else let y:ys'=ys | 2854 | else let y:ys'=ys |
2855 | in xs ++ (mergeSameSig n sig y : ys') | 2855 | in xs ++ (mergeSameSig n sig y : ys') |
2856 | |||
2857 | |||
2858 | isSameSig (a,_) (MappedPacket {packet=b},_) | isSignaturePacket a && isSignaturePacket b = | ||
2859 | a { unhashed_subpackets=[] } == b { unhashed_subpackets = [] } | ||
2860 | isSameSig (a,_) (MappedPacket {packet=b},_) = a==b | ||
2861 | |||
2862 | mergeSameSig :: Int -> (Packet,TrustMap) -> (MappedPacket,TrustMap) -> (MappedPacket, TrustMap) | ||
2863 | mergeSameSig n (a,ta) (m@(MappedPacket{packet=b,locations=locs}),tb) | isSignaturePacket a && isSignaturePacket b = | ||
2864 | ( m { packet = (b { unhashed_subpackets = | ||
2865 | foldl mergeItem (unhashed_subpackets b) (unhashed_subpackets a) }) | ||
2866 | , locations = Map.insert filename (origin a n) locs } | ||
2867 | , tb `Map.union` ta ) | ||
2868 | |||
2869 | where | 2856 | where |
2870 | -- TODO: when merging items, we should delete invalidated origins | 2857 | isSameSig (a,_) (MappedPacket {packet=b},_) | isSignaturePacket a && isSignaturePacket b = |
2871 | -- from the orgin map. | 2858 | a { unhashed_subpackets=[] } == b { unhashed_subpackets = [] } |
2872 | mergeItem ys x = if x `elem` ys then ys else ys++[x] | 2859 | isSameSig (a,_) (MappedPacket {packet=b},_) = a==b |
2873 | 2860 | ||
2874 | mergeSameSig n a b = b -- trace ("discarding dup "++show a) b | 2861 | mergeSameSig :: Int -> (Packet,TrustMap) -> (MappedPacket,TrustMap) -> (MappedPacket, TrustMap) |
2862 | mergeSameSig n (a,ta) (m@(MappedPacket{packet=b,locations=locs}),tb) | ||
2863 | | isSignaturePacket a && isSignaturePacket b = | ||
2864 | ( m { packet = b { unhashed_subpackets = | ||
2865 | union (unhashed_subpackets b) (unhashed_subpackets a) | ||
2866 | } | ||
2867 | , locations = Map.insert filename (origin a n) locs } | ||
2868 | -- TODO: when merging items, we should delete invalidated origins | ||
2869 | -- from the orgin map. | ||
2870 | , tb `Map.union` ta ) | ||
2871 | |||
2872 | mergeSameSig n a b = b -- trace ("discarding dup "++show a) b | ||
2875 | 2873 | ||
2876 | mergeUidSig n sig (Just (sigs,m)) = Just (mergeSig n sig sigs, m) | 2874 | mergeUidSig n sig (Just (sigs,m)) = Just (mergeSig n sig sigs, m) |
2877 | mergeUidSig n sig Nothing = Just ([asSigAndTrust n sig],Map.empty) | 2875 | mergeUidSig n sig Nothing = Just ([asSigAndTrust n sig],Map.empty) |