-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
coerce/from-string is a bit too naive (quite slow) #74
Comments
Parsing dates with
It's probably worth documenting that this is a slow method, but it is always going to be inherently slow to parse an arbitrary date format. You could conceivably speed it up by sorting the date formats or trying to do pre matching on regexes, or a bunch of other things, but I'm not sure if it's worth it. If you know up front which format you are going to be parsing, then cljs-time.format is a much safer and faster option. |
@danielcompton Yep! Agreed there, was just an example. |
TBH I'm not really motivated to "fix" this. It's present because the function is present in I'd be willing to accept a patch that improved things, provided it didn't add complexity to other parts of the library. |
Looks like all the exception handlers that get run end up making from-string pretty inefficient. It probably makes sense why this happens, but maybe should be documented as a trip-up. Not sure if my alternative is a particularly sane version (probably isn't, just a naive first attempt that happens to fit my use case). It could probably at least optimize to hit obvious types first (these are isoformat dates acting slow). Hit this because parsing just ~10-15 dates was making my page hundreds of times slower than expected.
The text was updated successfully, but these errors were encountered: