Skip to content

Commit 860b11f

Browse files
committed
Optimize JSON string encoding
There are a couple of optimizations that work together: - We now use the specialized php_next_utf8_char_mb() helper function to avoid pressure on the µop and instruction cache. - It no longer emits UTF-8 bytes under PHP_JSON_UNESCAPED_UNICODE until it actually has to. By emitting in bulk, this improves performance. - Code layout tweaks * Use a specialized php_json_append() and assertions to avoid allocating the initial buffer, as this is already done upfront. * Factor out the call to smart_str_extend() to above the UTF-16 check to avoid code bloat. - Use SIMD, either with SSE2 or SSE4.2. A resolver is used when SSE4.2 is not configured at compile time.
1 parent c3d7610 commit 860b11f

File tree

2 files changed

+317
-89
lines changed

2 files changed

+317
-89
lines changed

UPGRADING

+3
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,9 @@ PHP 8.5 UPGRADE NOTES
457457
14. Performance Improvements
458458
========================================
459459

460+
- JSON:
461+
. Encoding JSON strings without special characters is now faster.
462+
460463
- ReflectionProperty:
461464
. Improved performance of the following methods: getValue(), getRawValue(),
462465
isInitialized(), setValue(), setRawValue().

0 commit comments

Comments
 (0)
close