[wp-trac] [WordPress Trac] #23855: Leave Shortcode functions early, if there's no Shortcode delimiter

WordPress Trac noreply at wordpress.org
Fri Feb 28 10:09:16 UTC 2014


#23855: Leave Shortcode functions early, if there's no Shortcode delimiter
-------------------------+--------------------------
 Reporter:  TobiasBg     |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  3.9
Component:  Shortcodes   |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |     Focuses:  performance
-------------------------+--------------------------

Comment (by TobiasBg):

 Ok, that's somewhat embarrassing now... I tested the functionality of this
 change on the (correct) original patch
 [attachment:23855-shortcodes.patch], but failed to repeat that after
 refreshing coding standards in [attachment:23855.2.patch]. My bad, sorry.
 Won't happen again.

 So, [attachment:23855.3.patch] is the fixed patch.
 Additionally, I fixed/extended the test file [attachment:23855.test.2.php]
 a little bit, as it was actually testing the uncommon scenario of a non-
 existing Shortcode in its `has_shortcode()` test.

 Here are updated measurements (100,000 instead of 500,000 runs though) on
 a different server than my measurements from above:

 ||  ||Text with Shortcodes||Text without Shortcodes||
 ||`has_shortcode()` ||2.824s — unpatched||1.745s — unpatched||
 || +(`$tag` exists) ||2.896s — [attachment:23855.3.patch]||0.131s —
 [attachment:23855.3.patch]||
 ||`has_shortcode()` ||0.119s — unpatched||0.123s — unpatched||
 || +(`$tag` ~~exists~~) ||0.178s — [attachment:23855.3.patch]||0.132s —
 [attachment:23855.3.patch]||
 ||`do_shortcode()`  ||6.411s — unpatched||1.924s — unpatched||
 ||  ||6.491s — [attachment:23855.3.patch]||0.130s —
 [attachment:23855.3.patch]||
 ||`strip_shortcode()`||3.184s — unpatched||1.928s — unpatched||
 ||  ||3.254s — [attachment:23855.3.patch]||0.130s —
 [attachment:23855.3.patch]||

 As a consistency check: The patched functions, for text without
 Shortcodes, run `0.13(0|1|2)s`, which makes sense as they execute the same
 code in this scenario.

 Adding the check to `has_shortcode()` (and not just `do_shortcode()` and
 `strip_shortcodes()`) does also make sense, we were just measuring the
 wrong scenario.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/23855#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list