-
Notifications
You must be signed in to change notification settings - Fork 162
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 Encoder/Decoder instance? #172
Comments
That's a good question. There's an example in test/reuse-instances.test.ts, but they only accepts positional parameters right now, so I might change their interfaces to accept named parameters just like as |
Oh, just to clarify, I wasn't asking about the documentation. I was suggesting an optimization to the default |
Ah, sorry! Misunderstood. There're some reasons that we cannot memorize them:
|
Got it, that makes sense. If memoizing isn't an option, what about just pre-initializing a default instance that gets used when |
Sounds good. Will try it. |
Nice, thanks! I'd be happy to submit a PR if that would be helpful. |
The readme says that encoding is 20% faster when reusing an
Encoder
instance. If that's the case, is there any reason not to just memoize them inencode
(or at least reuse a default instance when no options are set)?The text was updated successfully, but these errors were encountered: