Skip to content

Remove 'indexOf' helper, use 'arr.indexOf()'#20194

Merged
1 commit merged into
masterfrom
index_of
Jan 8, 2018
Merged

Remove 'indexOf' helper, use 'arr.indexOf()'#20194
1 commit merged into
masterfrom
index_of

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Nov 21, 2017

Don't need this now that we're targeting ES5.

@ghost ghost requested a review from rbuckton November 21, 2017 16:10
@DanielRosenwasser
Copy link
Copy Markdown
Member

DanielRosenwasser commented Nov 21, 2017

A few things:

  1. Be careful given that the old indexOf is resilient to undefined arrays.
  2. Also, performance characteristics of built-ins isn't always as optimal as one would expect.
  3. Do we consider removals from core.ts to be breaks?

@ghost
Copy link
Copy Markdown
Author

ghost commented Nov 21, 2017

For 3), all of core.ts after line 20 is internal.

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Nov 21, 2017

what is the rational for this change? we do have multiple array/list helper functions that are hand-rolled, like map, filter, foreach, etc.. so what is the guiding principal here?

@ghost
Copy link
Copy Markdown
Author

ghost commented Nov 21, 2017

I think we should be removing any shim function once we move to an ES version that supports it natively. That might include contains (Array.includes), stringContains (String.includes) and find one day.
map and filter both handle undefined, which we use instead of empty arrays to reduce allocations; ideally we would use an immutable emptyArray for that (#16312), and then use builtin map and filter instead.
forEach is ambiguous over 3 different meanings, and should be replaced with a for loop, some, or find.

@ghost ghost merged commit fc18f08 into master Jan 8, 2018
@ghost ghost deleted the index_of branch January 8, 2018 18:39
@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants