Skip to content

Commit

Permalink
Switch the order of the maps to avoid unnecessary unionWith instead o…
Browse files Browse the repository at this point in the history
…f union
  • Loading branch information
josephcsible committed Jul 7, 2024
1 parent 61b7e66 commit 8746c6e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ShellCheck/CFGAnalysis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ internalToExternal s =
literalValue = Nothing
}
}
flatVars = M.unionsWith (\_ last -> last) $ map mapStorage [sGlobalValues s, sLocalValues s, sPrefixValues s]
flatVars = M.unions $ map mapStorage [sPrefixValues s, sLocalValues s, sGlobalValues s]

-- Conveniently get the state before a token id
getIncomingState :: CFGAnalysis -> Id -> Maybe ProgramState
Expand Down Expand Up @@ -672,7 +672,7 @@ vmPatch base diff =
_ | vmIsQuickEqual base diff -> diff
_ -> VersionedMap {
mapVersion = -1,
mapStorage = M.unionWith (flip const) (mapStorage base) (mapStorage diff)
mapStorage = M.union (mapStorage diff) (mapStorage base)
}

-- Set a variable. This includes properties. Applies it to the appropriate scope.
Expand Down Expand Up @@ -1373,7 +1373,7 @@ analyzeControlFlow params t =

-- Fill in the map with unreachable states for anything we didn't get to
let baseStates = M.fromDistinctAscList $ map (\c -> (c, (unreachableState, unreachableState))) $ uncurry enumFromTo $ nodeRange $ cfGraph cfg
let allStates = M.unionWith (flip const) baseStates invokedStates
let allStates = M.union invokedStates baseStates

-- Convert to external states
let nodeToData = M.map (\(a,b) -> (internalToExternal a, internalToExternal b)) allStates
Expand Down

0 comments on commit 8746c6e

Please sign in to comment.