[wp-trac] [WordPress Trac] #28724: Optimize Regexp Usage in wptexturize()

WordPress Trac noreply at wordpress.org
Wed Jul 2 19:36:58 UTC 2014

#28724: Optimize Regexp Usage in wptexturize()
 Reporter:  miqrogroove  |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Formatting   |    Version:
 Severity:  normal       |   Keywords:
  Focuses:               |
 The effort to consolidate patterns in #28623 didn't pan out.

 I think the next logical step in reducing CPU time in wptexturize is to
 structure the various patterns into groups by target and run them only if
 the target char(s) exist within the subject string.  As most of the
 patterns involve quotes or apostrophes, it should be faster to run strpos
 within the inner loop before running multiple regexp replacements.  If
 those replacements will do nothing, then they do not need to run during
 that one pass through the loop.


 This is a <i>test</i> post.

 Currently, all of the patterns would run 3 times each for that post.  With
 the proposed changes, we could run strpos about a dozen times and then
 exit wptexturize with the same results in less time.

Ticket URL: <https://core.trac.wordpress.org/ticket/28724>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list