levelup
levelup copied to clipboard
NotFoundError performance
Creating an Error for "NotFound" instead of just returning null
has a significant performance overhead. Creating Error objects are expensive.
Could we have a mode flag where we can avoid this?
Is this a real issue somewhere?
Some time later I want to remove the (IMO usually unhelpful) error and return undefined
instead. Per https://github.com/Level/community/issues/76.
@ronag For the short term, I'd say pull requests to make this behavior opt-in are welcome, but it does depend on which modules you're using. You'll also have to touch any implementation of abstract-leveldown
that you're using, because levelup
merely wraps the errors. If this involves too many modules, I'm reluctant to accept PRs, because I want to wind down the maintenance of these, in favor of abstract-level
.
Quick and dirty benchmark of error (!undef
) vs undefined:
https://github.com/Level/abstract-level/pull/49