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

Less .catch(reject) -> less in mem promises in IndexedDb driver #1034

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

duzun
Copy link
Contributor

@duzun duzun commented Aug 19, 2021

This PR is a small pattern change in indexeddb.js that should result a an unnoticeable performance improvement, by having one less promise instance in memory at a given moment in time for each method call on the driver.

This also removes the unnecessary call to .catch(reject).

The old pattern:

var promise = new Promise(function (resolve, reject) {
	self
      	.ready()
      	.then(function() {
		  // ...
	  	})
		.catch(reject);
	});

The new pattern:

var promise = self
      .ready()
      .then(function() {
          return new Promise(function (resolve, reject) {
		  // ...
	  });
  });

The new Promise is created after instance.ready() has resolved, thus delayed, thus existing in mem for a shorter period of time.

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.

None yet

1 participant