1
0
mirror of https://github.com/halaxa/json-machine.git synced 2025-01-29 10:28:09 +01:00

Compilation optimizations

This commit is contained in:
Filip Halaxa 2022-03-02 21:53:56 +01:00
parent d6f99f366e
commit 62bf9ce03e
5 changed files with 15 additions and 9 deletions

View File

@ -121,8 +121,11 @@ zephir: ## Build JSON Machine's PHP extension
"\
cd /json-machine/ext/jsonmachine \
&& zephir fullclean \
&& zephir build \
&& zephir generate \
&& zephir compile --no-dev \
&& zephir install --no-dev \
&& zephir stubs \
&& cd /json-machine \
&& vendor/bin/phpunit \
&& php test/performance/testPerformance.php \
"

View File

@ -723,7 +723,7 @@
{
"type": "if",
"expr": {
"type": "list",
"type": "unlikely",
"left": {
"type": "property-access",
"left": {
@ -731,22 +731,22 @@
"value": "this",
"file": "\/json-machine\/ext\/jsonmachine\/jsonmachine\/exttokens.zep",
"line": 63,
"char": 22
"char": 30
},
"right": {
"type": "variable",
"value": "escaping",
"file": "\/json-machine\/ext\/jsonmachine\/jsonmachine\/exttokens.zep",
"line": 63,
"char": 31
"char": 40
},
"file": "\/json-machine\/ext\/jsonmachine\/jsonmachine\/exttokens.zep",
"line": 63,
"char": 31
"char": 40
},
"file": "\/json-machine\/ext\/jsonmachine\/jsonmachine\/exttokens.zep",
"line": 63,
"char": 33
"char": 40
},
"statements": [
{

View File

@ -181,7 +181,7 @@ PHP_METHOD(JsonMachine_ExtTokens, next)
ZEPHIR_INIT_NVAR(&byte);
zephir_substr(&byte, &_6$$3, zephir_get_intval(&_7$$3), 1 , 0);
zephir_read_property(&_9$$3, this_ptr, ZEND_STRL("escaping"), PH_NOISY_CC | PH_READONLY);
if (zephir_is_true(&_9$$3)) {
if (UNEXPECTED(zephir_is_true(&_9$$3))) {
if (0) {
zephir_update_property_zval(this_ptr, ZEND_STRL("escaping"), &__$true);
} else {

View File

@ -60,7 +60,7 @@ class ExtTokens implements \Iterator
return;
}
let byte = substr(this->chunk, this->chunkIndex, 1);
if (this->escaping) {
if unlikely this->escaping {
let this->escaping = false;
let this->tokenBuffer = this->tokenBuffer . byte;
let this->chunkIndex++;

View File

@ -2,7 +2,10 @@
declare(strict_types=1);
use JsonMachine\ExtTokens;
use JsonMachine\FileChunks;
use JsonMachine\Items;
use JsonMachine\Parser;
require_once __DIR__.'/../../vendor/autoload.php';
@ -20,7 +23,7 @@ $decoders = [
return Items::fromFile($file, ['debug' => true]);
},
'Items::fromFile() - ext' => function ($file) {
return new \JsonMachine\Parser();
return new Parser(new ExtTokens((new FileChunks($file))->getIterator()));
},
'json_decode()' => function ($file) {
return json_decode(stream_get_contents(fopen($file, 'r')), true);