From c48d2b4a5880af0eb3fdfe66aecc349f4d18f631 Mon Sep 17 00:00:00 2001 From: Zentrik Date: Thu, 4 Jan 2024 00:09:19 +0000 Subject: [PATCH 1/3] Fix DEFAULT_PARSERCONTEXT, speed up parsing. Unfortunately this was never updated in #280 to be the correct default, and so has been wrong ever since introduction. --- src/Parser.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Parser.jl b/src/Parser.jl index 6bc5df2..1625c13 100644 --- a/src/Parser.jl +++ b/src/Parser.jl @@ -415,9 +415,9 @@ function unparameterize_type(T::Type) end # Workaround for slow dynamic dispatch for creating objects -const DEFAULT_PARSERCONTEXT = ParserContext{Dict{String, Any}, Int64, false, nothing}() +const DEFAULT_PARSERCONTEXT = ParserContext{Dict{String, Any}, Int64, true, nothing}() function _get_parsercontext(dicttype, inttype, allownan, null) - if dicttype == Dict{String, Any} && inttype == Int64 && !allownan + if dicttype == Dict{String, Any} && inttype == Int64 && allownan DEFAULT_PARSERCONTEXT else ParserContext{unparameterize_type(dicttype), inttype, allownan, null}.instance From c271ae115faa093cf17367686adbbb2f59e3c223 Mon Sep 17 00:00:00 2001 From: Zentrik Date: Thu, 4 Jan 2024 00:10:07 +0000 Subject: [PATCH 2/3] Fix preexisting bug --- src/Parser.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Parser.jl b/src/Parser.jl index 1625c13..d9041d9 100644 --- a/src/Parser.jl +++ b/src/Parser.jl @@ -417,7 +417,7 @@ end # Workaround for slow dynamic dispatch for creating objects const DEFAULT_PARSERCONTEXT = ParserContext{Dict{String, Any}, Int64, true, nothing}() function _get_parsercontext(dicttype, inttype, allownan, null) - if dicttype == Dict{String, Any} && inttype == Int64 && allownan + if dicttype == Dict{String, Any} && inttype == Int64 && allownan && isnothing(null) DEFAULT_PARSERCONTEXT else ParserContext{unparameterize_type(dicttype), inttype, allownan, null}.instance From bd341d2e2e40afbd3b2cbc8b2f21c29fb93f2932 Mon Sep 17 00:00:00 2001 From: Zentrik Date: Thu, 4 Jan 2024 00:13:31 +0000 Subject: [PATCH 3/3] Fix for Julia 1.0 --- src/Parser.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Parser.jl b/src/Parser.jl index d9041d9..ca9f33a 100644 --- a/src/Parser.jl +++ b/src/Parser.jl @@ -417,7 +417,7 @@ end # Workaround for slow dynamic dispatch for creating objects const DEFAULT_PARSERCONTEXT = ParserContext{Dict{String, Any}, Int64, true, nothing}() function _get_parsercontext(dicttype, inttype, allownan, null) - if dicttype == Dict{String, Any} && inttype == Int64 && allownan && isnothing(null) + if dicttype == Dict{String, Any} && inttype == Int64 && allownan && null === nothing DEFAULT_PARSERCONTEXT else ParserContext{unparameterize_type(dicttype), inttype, allownan, null}.instance