Skip to content
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

Reuse RFC3339DateFormatter when encoding/decoding a JSONFeed #180

Merged
merged 3 commits into from
Mar 15, 2025

Conversation

sebj
Copy link
Contributor

@sebj sebj commented Mar 15, 2025

Three small changes relating to date formatters, each in a separate commit:

  • Reuse RFC3339DateFormatter when encoding or decoding a JSONFeed
    • Totally open to suggestions on the formatting/style of this to fit the project
  • Make date formatter classes final – seemed like an optimization to be made, given it's unlikely these will be subclassed
  • Added a mention of RFC 1123 to the documentation comment of FeedDateFormatter, which currently supports multiple specs

@nmdias
Copy link
Owner

nmdias commented Mar 15, 2025

Hi @sebj

Looks great 😄 Reusing the formatter makes sense and making others final is a nice optimization.

swift format should take care of any formatting/style 🚀

Thank you so much.

@nmdias nmdias merged commit 2abd795 into nmdias:main Mar 15, 2025
7 checks passed
nmdias added a commit that referenced this pull request Mar 15, 2025
@nmdias
Copy link
Owner

nmdias commented Mar 15, 2025

@sebj just something I noticed now.

I created a branch reuse-date-formatters to test out moving all formatters to a shared instance, but an issue may came up. In batch processing feeds a shared instance is mutated by multiple threads. The dateFormat changes as it attempts to parse multiple date formats. JSON feeds aren't so popular, so the issue is very unlikely to present itself there.

@sebj sebj deleted the reuse-rfc-3339-dateformatter branch March 15, 2025 21:52
@sebj
Copy link
Contributor Author

sebj commented Mar 15, 2025

Ah right, sorry I didn't quite realise that when making my initial change here – that's a little annoying

@nmdias
Copy link
Owner

nmdias commented Mar 16, 2025

All is good, I kept everything else on the main branch and rc.6

Thank you 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants