#17129 closed enhancement (fixed)
Speed up is_serialized_string()
| Reported by: | markjaquith | Owned by: | markjaquith |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.2 |
| Component: | Performance | Version: | |
| Severity: | minor | Keywords: | reporter-feedback |
| Cc: | Focuses: |
Description
is_serialized_string() uses an expensive regular expression. It should use substring peeking like is_serialized() does. In my tests, this offers a time reduction of about 26%.
Attachments (2)
Change History (9)
#4
@
15 years ago
- Keywords reporter-feedback added
When I reviewed the changeset this is what came into my mind. I have not benchmarked so far if it's actually faster than the if / else approach.
#6
@
15 years ago
A note of caution: is_serialized_string() will return true for cases is_serialized() will return false. So both functions are not compatible with each other.
Related: #17375
As is_serialized_string() is used in core only after if(is_serialized()) has been true, and it's not same stage compatible, it could be even written much smaller by just checking for s/S as the first letter.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Edit: Oops, Ignore What I've said...
the last elseif can be changed to
elseif ( '"' !== $data[4] || '"' !== $data[$length-2] ) return false;