Opened on 06/07/2018 at 09:50:31 AM

Closed on 06/07/2018 at 10:07:21 AM

#6737 closed change (fixed)

Use String.includes instead of String.indexOf where the index is not needed

Reported by: mjethani Assignee: mjethani
Priority: P3 Milestone:
Module: Core Keywords:
Cc: sergz, kzar, jsonesen Blocked By:
Blocking: #6425 Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Unknown Verified working: no
Review URL(s):

https://codereview.adblockplus.org/29801558/

Description

Background

We use String.indexOf and compare the return value with -1 when we want to check if a string contains a given string. ECMAScript 2015 introduced a new String.includes method which is a lot more straightforward and does not affect performance negatively. It is supported on all our supported platforms.

What to change

Where the index of a search string is irrelevant and the objective is only to check if the search string occurs anywhere in a given string, replace the use of String.indexOf with String.includes.

Attachments (0)

Change History (3)

comment:1 Changed on 06/07/2018 at 10:01:39 AM by mjethani

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing

comment:2 Changed on 06/07/2018 at 10:06:45 AM by abpbot

A commit referencing this issue has landed:
Issue 6737 - Use String.includes instead of String.indexOf

comment:3 Changed on 06/07/2018 at 10:07:21 AM by mjethani

  • Resolution set to fixed
  • Status changed from reviewing to closed

Add Comment

Modify Ticket

Change Properties
Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from mjethani.
 
Note: See TracTickets for help on using tickets.