[wp-trac] [WordPress Trac] #14429: Faster is_serialized
WordPress Trac
wp-trac at lists.automattic.com
Mon Sep 20 23:51:36 UTC 2010
#14429: Faster is_serialized
--------------------------+-------------------------------------------------
Reporter: sambauers | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 3.1
Component: Optimization | Version: 3.0
Severity: minor | Keywords: has-patch
--------------------------+-------------------------------------------------
Comment(by Denis-de-Bernardy):
r15636 honestly doesn't seem to make any sense. Shouldn't we be using
something more like this?
{{{
if ( isset($data[1]) && $data[1] == ':' && strpbrk($data[0],'adObis') ==
$data[0] ) {
}}}
or even:
{{{
if ( isset($data[1]) && $data[1] == ':' && in_array($data[0], array('a',
'd', 'O', 'b', 'i', 's') ) {
}}}
It's like... there's absolutely no point in a) calculating the length of a
1MB string to verifying that its second char is set, b) doing some complex
comparison involving strpbrk() (which could potentially amount to finding
the first of these chars at the very end of a 1MB string) and c) only
*then* verifying that the second character works for our sake.
Better: a) check that the second character exists at all, b) verify that
it works, and c) finally look at the first chars to see if it works...
My $.02...
--
Ticket URL: <http://core.trac.wordpress.org/ticket/14429#comment:10>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list