Closed johnswanson closed 7 years ago
Thanks for catching this!
I think @danielcompton has a point. It's possibly better to defn-
this, or at least locally let
a fn
outside the loop
, but I'll happily merge as is.
Thanks @andrewmcveigh and @danielcompton, sorry for missing the comment re: creating the function within the loop until now! That makes sense to me, I'd be happy to create another PR doing the defn-
instead.
Profiling an application that's parsing a thousand or so dates at a time, I found that 75% of the time was spent constructing
ex-info
s (specifically, it looks like getting the stack is a very expensive operation).In most parsing cases, we probably won't actually be throwing any error, so instead of wastefully constructing the
ex-info
every time, we can just construct it when it's actually thrown.I did this by just throwing the ex-info generation into a separate function, to avoid code repetition.