Skip to content

Commit

Permalink
slightly improve type instability and add a precompile statement (#5)
Browse files Browse the repository at this point in the history
* slightly improve type instability and add a precompile statement

* simplified precompile
  • Loading branch information
KristofferC authored Oct 23, 2021
1 parent efa8240 commit 557df21
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/VersionParsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -76,4 +76,6 @@ function vparse(s_::String)
end
end

precompile(Tuple{typeof(vparse), String})

end # module

0 comments on commit 557df21

Please sign in to comment.