haskellari / postgresql-libpq

Low-level Haskell bindings for libpq
BSD 3-Clause "New" or "Revised" License
20 stars 27 forks source link

withParams*: drop redundant call to 'length' by using 'withArrayLen' #32

Closed robx closed 1 year ago

robx commented 2 years ago

This is the other left-over change from #22.

I'm a bit unsure whether this is a net win: It saves us one out of several redundant list length computing the parameter length list and a few lines of code, at the expense of arbitrarily breaking symmetry between the different equally long lists.

The nicer way to optimize this might be if Foreign.Marshal exposed something like unsafeWithArray len vals action.

phadej commented 1 year ago

I noticed this just now. I think using unsafeWithArray is cleaner so I did so: https://github.com/haskellari/postgresql-libpq/pull/33