WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#3920 closed enhancement (fixed)

Use strpos() instead of strstr() where appropriate

Reported by: rob1n Owned by: rob1n
Milestone: 2.2 Priority: normal
Severity: normal Version: 2.1.2
Component: Optimization Keywords: has-patch
Focuses: Cc:

Description

According to the PHP manual page, strpos() is "faster and less memory intensive" (http://us2.php.net/strstr) than strstr() if you just want to know whether a string contains another string.

After talking with Ryan, I made a patch that changes every strstr() call to a strpos() (*except* where appropriate for strstr()).

Attachments (3)

3290.diff (26.5 KB) - added by rob1n 7 years ago.
3920.2.diff (27.0 KB) - added by rob1n 7 years ago.
Fix typo noticed by MarkJaquith.
3920.3.diff (27.0 KB) - added by johnbillion 7 years ago.
Fixes typo on line 280 of pluggable.php from patch 3920.2

Download all attachments as: .zip

Change History (9)

rob1n7 years ago

comment:1 rob1n7 years ago

  • Keywords has-patch added
  • Status changed from new to assigned
  • Type changed from defect to enhancement

Never mind the incorrect file name, I swear I'm slightly dyslexic sometimes.

rob1n7 years ago

Fix typo noticed by MarkJaquith.

comment:2 markjaquith7 years ago

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

(In [4990]) Use strpos instead of strstr where ever possible, for speed. Props rob1n. fixes #3920

comment:3 johnbillion7 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

There's a bug in this patch, I'll fix and submit a new one in a minute.

johnbillion7 years ago

Fixes typo on line 280 of pluggable.php from patch 3920.2

comment:4 johnbillion7 years ago

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

Attached patch 3920.3 to fix typo on line 280 of pluggable.php from patch 3920.2.

comment:5 markjaquith7 years ago

(In [4995]) Typo in [4990] caught by johnbillion. fixes #3920

comment:6 markjaquith7 years ago

(In [4996]) Another typo in [4990]. fixes #3920

Note: See TracTickets for help on using tickets.