Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#15093 closed enhancement (fixed)

wptexturize() efficiency improvement: remove unnecessary repetition operators

Reported by: mdawaffe's profile mdawaffe Owned by:
Milestone: 3.1 Priority: normal
Severity: normal Version:
Component: Formatting Keywords: has-patch
Focuses: Cc:

Description

There are few regular expressions in wptexturize() that are used to match strings of the form /(\d+){suffix}/ or /{prefix}(\d+)/ for replacement with {something else}$1 or $1{something else}, respectively.

The repetition operator is not needed; matching only the last (or first) digit in the series of digits is equivalent. Since the repetition operator will cause more backtracing when processing the regular expression, removing it will increase efficiency.

In my (very naive) tests, I found about a 2% speed increase when removing those repetition operators.

Patch attached.

Attachments (1)

15093.diff (1.2 KB) - added by mdawaffe 13 years ago.

Download all attachments as: .zip

Change History (3)

@mdawaffe
13 years ago

#1 @nacin
13 years ago

  • Component changed from General to Formatting
  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 3.1

#2 @ryan
13 years ago

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

(In [15816]) Improve regex performance in wptexturize(). Props mdawaffe. fixes #15093

Note: See TracTickets for help on using tickets.