Ticket #3920 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

Use strpos() instead of strstr() where appropriate

Reported by: rob1n Assigned to: rob1n
Priority: normal Milestone: 2.2
Component: Optimization Version: 2.1.2
Severity: normal Keywords: has-patch
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

3290.diff (26.5 kB) - added by rob1n on 03/07/07 04:04:31.
3920.2.diff (27.0 kB) - added by rob1n on 03/07/07 05:10:26.
Fix typo noticed by MarkJaquith?.
3920.3.diff (27.0 kB) - added by johnbillion on 03/07/07 06:00:22.
Fixes typo on line 280 of pluggable.php from patch 3920.2

Change History

03/07/07 04:04:31 changed by rob1n

  • attachment 3290.diff added.

03/07/07 04:05:08 changed by rob1n

  • keywords set to has-patch.
  • 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.

03/07/07 05:10:26 changed by rob1n

  • attachment 3920.2.diff added.

Fix typo noticed by MarkJaquith?.

03/07/07 05:29:28 changed by markjaquith

  • status changed from assigned to closed.
  • resolution set to fixed.

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

03/07/07 05:55:08 changed by johnbillion

  • status changed from closed to reopened.
  • resolution deleted.

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

03/07/07 06:00:22 changed by johnbillion

  • attachment 3920.3.diff added.

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

03/07/07 06:01:15 changed by johnbillion

  • status changed from reopened to closed.
  • resolution set to fixed.

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

03/07/07 06:10:35 changed by markjaquith

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

03/07/07 06:17:17 changed by markjaquith

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