hermes icon indicating copy to clipboard operation
hermes copied to clipboard

Add fast path for Array.prototype.indexOf/lastIndexOf

Open lavenzg opened this issue 1 year ago • 3 comments

Summary: If this is truly an Array object, go fast path, otherwise, falls to slow path. In fast path, use specialized loop given the type of search value and reverse mode. For checking Number, add a new function that returns double value if the HV is a number and returns NaN if it's not. This avoids repeated tag checking in isNumber() and getNumber() for HV32 mode.

On the given benchmark it's ~12X faster on both HV32 and HV64 mode.

Differential Revision: D58201521

lavenzg avatar Jun 24 '24 07:06 lavenzg

This pull request was exported from Phabricator. Differential Revision: D58201521

facebook-github-bot avatar Jun 24 '24 07:06 facebook-github-bot

This pull request was exported from Phabricator. Differential Revision: D58201521

facebook-github-bot avatar Jun 24 '24 17:06 facebook-github-bot

Nice! For the reference: this fixes https://github.com/facebook/hermes/issues/1270 Related to https://github.com/facebook/hermes/issues/1573 and https://github.com/facebook/react-native/issues/36296

miallo avatar Jul 03 '24 11:07 miallo