Make WordPress Core

Opened 18 years ago

Closed 18 years ago

Last modified 2 years ago

#3920 closed enhancement (fixed)

Use strpos() instead of strstr() where appropriate

Reported by: rob1n's profile rob1n Owned by: rob1n's profile rob1n
Milestone: 2.2 Priority: normal
Severity: normal Version: 2.1.2
Component: Optimization Keywords: has-patch has-unit-tests
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 18 years ago.
3920.2.diff (27.0 KB) - added by rob1n 18 years ago.
Fix typo noticed by MarkJaquith.
3920.3.diff (27.0 KB) - added by johnbillion 18 years ago.
Fixes typo on line 280 of pluggable.php from patch 3920.2

Download all attachments as: .zip

Change History (10)

@rob1n
18 years ago

#1 @rob1n
18 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.

@rob1n
18 years ago

Fix typo noticed by MarkJaquith.

#2 @markjaquith
18 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

#3 @johnbillion
18 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.

@johnbillion
18 years ago

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

#4 @johnbillion
18 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.

#5 @markjaquith
18 years ago

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

#6 @markjaquith
18 years ago

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

This ticket was mentioned in PR #3971 on WordPress/wordpress-develop by @flixos90.


2 years ago
#7

  • Keywords has-unit-tests added

Not intended for commit.

This PR is solely for QA and performance testing of #3920. It is based on the same code, but also includes initial usage of that new API, which were taken from #3914 and https://github.com/dmsnell/wordpress-develop/pull/1.

Note: See TracTickets for help on using tickets.