Skip to content

Commit bc69f4b

Browse files
committed
withParams*: drop redundant map
Instead of building a list of 'Int' in the fold, and then mapping 'toEnum' over it, build a list of 'CInt' directly.
1 parent 361e088 commit bc69f4b

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/Database/PostgreSQL/LibPQ.hsc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -759,9 +759,8 @@ withParams params action =
759759
withArray formats $ \fs ->
760760
action n ts vs ls fs
761761
where
762-
(oids, values, lengths, formats) =
762+
(oids, values, c_lengths, formats) =
763763
foldl' accum ([],[],[],[]) $ reverse params
764-
!c_lengths = map toEnum lengths :: [CInt]
765764
!n = toEnum $ length params
766765

767766
accum (!a,!b,!c,!d) Nothing = ( invalidOid:a
@@ -771,7 +770,7 @@ withParams params action =
771770
)
772771
accum (!a,!b,!c,!d) (Just (t,v,f)) = ( t:a
773772
, (Just v):b
774-
, (B.length v):c
773+
, (toEnum $ B.length v):c
775774
, (toEnum $ fromEnum f):d
776775
)
777776

@@ -787,16 +786,15 @@ withParamsPrepared params action =
787786
withArray formats $ \fs ->
788787
action n vs ls fs
789788
where
790-
(values, lengths, formats) = foldl' accum ([],[],[]) $ reverse params
791-
!c_lengths = map toEnum lengths :: [CInt]
789+
(values, c_lengths, formats) = foldl' accum ([],[],[]) $ reverse params
792790
!n = toEnum $ length params
793791

794792
accum (!a,!b,!c) Nothing = ( Nothing:a
795793
, 0:b
796794
, 0:c
797795
)
798796
accum (!a,!b,!c) (Just (v, f)) = ( (Just v):a
799-
, (B.length v):b
797+
, (toEnum $ B.length v):b
800798
, (toEnum $ fromEnum f):c
801799
)
802800

0 commit comments

Comments
 (0)