From d7bbeb1d8fb5cf9f507ac1f19de226ba226054c8 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Mon, 20 Dec 2021 16:27:58 +0100 Subject: [PATCH] fix default options --- ion.c | 18 +++++++++--------- ion.stub.php | 14 ++++++-------- ion_arginfo.h | 12 ++++++------ ion_private.h | 3 +-- 4 files changed, 22 insertions(+), 25 deletions(-) diff --git a/ion.c b/ion.c index 5d10462..3dc454a 100644 --- a/ion.c +++ b/ion.c @@ -588,8 +588,8 @@ static ZEND_METHOD(ion_Reader_Options, __construct) { php_ion_reader_options *opt = php_ion_obj(reader_options, Z_OBJ_P(ZEND_THIS)); zend_bool ret_sys_val = false, skip_validation = false; - zend_long ch_nl = 0xa, max_depth = 10, max_ann, max_ann_buf = 512, - sym_thr = 0x1000, uval_thr = 0x1000, chunk_thr = 0x1000, alloc_pgsz = 0x1000; + zend_long ch_nl = 0xa, max_depth = 10, max_ann = 10, max_ann_buf = 512, + sym_thr = 0x4000, uval_thr = 0x4000, chunk_thr = 0x4000, alloc_pgsz = 0x10000; PTR_CHECK(opt); @@ -611,13 +611,13 @@ static ZEND_METHOD(ion_Reader_Options, __construct) Z_PARAM_LONG(max_ann) // public readonly int $maxAnnotationBuffered = 512, Z_PARAM_LONG(max_ann_buf) - // public readonly int $symbolThreshold = 4096, + // public readonly int $symbolThreshold = 0x4000, Z_PARAM_LONG(sym_thr) - // public readonly int $userValueThreshold = 4096, + // public readonly int $userValueThreshold = 0x4000, Z_PARAM_LONG(uval_thr) - // public readonly int $chunkThreshold = 4096, + // public readonly int $chunkThreshold = 0x4000, Z_PARAM_LONG(chunk_thr) - // public readonly int $allocationPageSize = 4096, + // public readonly int $allocationPageSize = 0x10000, Z_PARAM_LONG(alloc_pgsz) // public readonly bool $skipCharacterValidation = false, Z_PARAM_BOOL(skip_validation) @@ -1201,7 +1201,7 @@ static ZEND_METHOD(ion_Writer_Options, __construct) zend_bool binary = false, compact_floats = false, escape = false, pretty = false, tabs = true, small_cntr_inl = true, suppress_sys = false, flush = false; - zend_long indent = 2, max_depth = 10, max_ann = 10, temp = 0x400, alloc = 0x1000; + zend_long indent = 2, max_depth = 10, max_ann = 10, temp = 0x4000, alloc = 0x10000; ZEND_PARSE_PARAMETERS_START(0, 16) Z_PARAM_OPTIONAL //public readonly ?\ion\Catalog $catalog = null, @@ -1232,9 +1232,9 @@ static ZEND_METHOD(ion_Writer_Options, __construct) Z_PARAM_LONG(max_depth) //public readonly int $maxAnnotations = 10, Z_PARAM_LONG(max_ann) - //public readonly int $tempBufferSize = 0x400, + //public readonly int $tempBufferSize = 0x4000, Z_PARAM_LONG(temp) - //public readonly int $allocationPageSize = 0x1000, + //public readonly int $allocationPageSize = 0x10000, Z_PARAM_LONG(alloc) ZEND_PARSE_PARAMETERS_END(); diff --git a/ion.stub.php b/ion.stub.php index 8e5d6ac..e7a977d 100644 --- a/ion.stub.php +++ b/ion.stub.php @@ -296,10 +296,10 @@ class Options { public readonly int $maxContainerDepth = 10, public readonly int $maxAnnotations = 10, public readonly int $maxAnnotationBuffered = 512, - public readonly int $symbolThreshold = 4096, - public readonly int $userValueThreshold = 4096, - public readonly int $chunkThreshold = 4096, - public readonly int $allocationPageSize = 4096, + public readonly int $symbolThreshold = 0x4000, + public readonly int $userValueThreshold = 0x4000, + public readonly int $chunkThreshold = 0x4000, + public readonly int $allocationPageSize = 0x10000, public readonly bool $skipCharacterValidation = false, ) {} } @@ -413,11 +413,9 @@ class Options { public readonly bool $flushEveryValue = false, public readonly int $maxContainerDepth = 10, public readonly int $maxAnnotations = 10, - public readonly int $tempBufferSize = 0x400, - public readonly int $allocationPageSize = 0x1000, + public readonly int $tempBufferSize = 0x4000, + public readonly int $allocationPageSize = 0x10000, ) {} - - // public function addSharedImports(\ion\Collection|\ion\Symbol\Table ...$imports) : void; } namespace ion; diff --git a/ion_arginfo.h b/ion_arginfo.h index da8a3fb..3a94e5f 100644 --- a/ion_arginfo.h +++ b/ion_arginfo.h @@ -247,10 +247,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ion_Reader_Options___construct, 0, 0, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maxContainerDepth, IS_LONG, 0, "10") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maxAnnotations, IS_LONG, 0, "10") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maxAnnotationBuffered, IS_LONG, 0, "512") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, symbolThreshold, IS_LONG, 0, "4096") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, userValueThreshold, IS_LONG, 0, "4096") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, chunkThreshold, IS_LONG, 0, "4096") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, allocationPageSize, IS_LONG, 0, "4096") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, symbolThreshold, IS_LONG, 0, "0x4000") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, userValueThreshold, IS_LONG, 0, "0x4000") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, chunkThreshold, IS_LONG, 0, "0x4000") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, allocationPageSize, IS_LONG, 0, "0x10000") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, skipCharacterValidation, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() @@ -374,8 +374,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ion_Writer_Options___construct, 0, 0, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flushEveryValue, _IS_BOOL, 0, "false") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maxContainerDepth, IS_LONG, 0, "10") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maxAnnotations, IS_LONG, 0, "10") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, tempBufferSize, IS_LONG, 0, "0x400") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, allocationPageSize, IS_LONG, 0, "0x1000") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, tempBufferSize, IS_LONG, 0, "0x4000") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, allocationPageSize, IS_LONG, 0, "0x10000") ZEND_END_ARG_INFO() #define arginfo_class_ion_Writer_writeNull arginfo_class_ion_Reader_Reader_rewind diff --git a/ion_private.h b/ion_private.h index 4146fde..0070754 100644 --- a/ion_private.h +++ b/ion_private.h @@ -1026,8 +1026,7 @@ static inline void php_ion_reader_ctor(php_ion_reader *obj) PTR_CHECK(obj->stream.ptr); GC_ADDREF(obj->stream.ptr->res); - php_ion_reader_options *opt = php_ion_obj(reader_options, obj->opt); - obj->stream.buf.length = opt ? opt->opt.allocation_page_size : 0x1000; + obj->stream.buf.length = opt && opt->opt.allocation_page_size ? opt->opt.allocation_page_size : 0x10000; obj->stream.buf.value = emalloc(obj->stream.buf.length); err = ion_reader_open_stream(&obj->reader, obj, php_ion_reader_stream_handler, opt ? &opt->opt : NULL); -- 2.30.2