Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: Minor performance improvement of BackHandler.removeEventLis…
…tener (#34281) Summary: I've noticed that `BackHandler.removeEventListener()` performs two same `indexOf()` calls on an array that is not changing. By removing extra `indexOf` we can slightly improve time complexity of `BackHandler.removeEventListener()` from O(2n) to O(n) ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [Android] [Fixed] - Remove extra indexOf call in BackHandler.removeEventListener Pull Request resolved: #34281 Test Plan: 1. Add the following code to any function component ```javascript BackHandler.addEventListener('hardwareBackPress', () => true).remove(); ``` 2. Press on hardware back button Expected result: Application closes Reviewed By: dmitryrykun Differential Revision: D38198510 Pulled By: javache fbshipit-source-id: eab6a57689a536623138a4b3ebddbf9ba87d281f
- Loading branch information