From 8be01089d500e499a6e7f2a375b92bcacac40072 Mon Sep 17 00:00:00 2001 From: KristofferC Date: Tue, 27 Apr 2021 17:07:30 +0200 Subject: [PATCH 1/2] slightly improve type instability and add a precompile statement --- src/VersionParsing.jl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/VersionParsing.jl b/src/VersionParsing.jl index b3de9a5..48ff659 100644 --- a/src/VersionParsing.jl +++ b/src/VersionParsing.jl @@ -34,7 +34,7 @@ For example, vparse(s::AbstractString) = vparse(String(s)) digits2num(s::AbstractString) = all(isdigit, s) ? parse(Int, s) : s -splitparts(s::AbstractString) = map(digits2num, filter!(!isempty, split(s, '.'))) +splitparts(s::T) where {T <: AbstractString} = Union{Int, T}[digits2num(x) for x in filter!(!isempty, split(s, '.'))] function vparse(s_::String) s = replace(s_, r"^[^\d]*[^.\d](\.?\d)"=>s"\1") # strip non-numeric prefix @@ -76,4 +76,10 @@ function vparse(s_::String) end end +function _precompile_() + ccall(:jl_generating_output, Cint, ()) == 1 || return nothing + precompile(Tuple{typeof(VersionParsing.vparse), String}) +end +_precompile_() + end # module From b8f7249d89576f9a2667046569fa10eded072d94 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Mon, 18 Oct 2021 14:25:11 +0200 Subject: [PATCH 2/2] simplified precompile --- src/VersionParsing.jl | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/VersionParsing.jl b/src/VersionParsing.jl index 48ff659..9e42fab 100644 --- a/src/VersionParsing.jl +++ b/src/VersionParsing.jl @@ -76,10 +76,6 @@ function vparse(s_::String) end end -function _precompile_() - ccall(:jl_generating_output, Cint, ()) == 1 || return nothing - precompile(Tuple{typeof(VersionParsing.vparse), String}) -end -_precompile_() +precompile(Tuple{typeof(vparse), String}) end # module