From 5910383d5679fb065a0f382564b6d97ec949e258 Mon Sep 17 00:00:00 2001 From: ScottPJones Date: Thu, 22 Oct 2026 13:35:53 -0400 Subject: [PATCH] Remove old support for < julia v1.0 --- Project.toml | 2 +- src/StrTables.jl | 40 +++++++++++++--------------------------- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/Project.toml b/Project.toml index cab6687..4eef3ac 100644 --- a/Project.toml +++ b/Project.toml @@ -4,7 +4,7 @@ keywords = ["Strings"] license = "MIT" name = "StrTables" uuid = "9700d1a9-a7c8-5760-9816-a99fda30bb8f" -version = "1.0.1" +version = "1.1" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" diff --git a/src/StrTables.jl b/src/StrTables.jl index 435c86d..5edf61f 100644 --- a/src/StrTables.jl +++ b/src/StrTables.jl @@ -1,9 +1,8 @@ -__precompile__() """ Simple String Table and load/save functions Author: Scott Paul Jones -Copyright: 2017-2018 Gandalf Software, Inc (and any future contributors) +Copyright: 2017-2021 Gandalf Software, Inc (and any future contributors) License: MIT (see https://github.com/JuliaString/StrTables.jl/blob/master/LICENSE.md) ## Public API: @@ -24,26 +23,19 @@ License: MIT (see https://github.com/JuliaString/StrTables.jl/blob/master/LIC module StrTables export StrTable, PackedTable, AbstractPackedTable, AbstractEntityTable -const V6_COMPAT = VERSION < v"0.7-" - # Utility functions for building tables export create_vector, sortsplit!, _contains, _replace, _codeunits, cvt_char, parse_hex -parse_hex(T, s) = @static V6_COMPAT ? parse(T, s, 16) : parse(T, s, base=16) -cvt_char(s) = @static V6_COMPAT ? convert(Vector{Char}, s) : Vector{Char}(s) -_codeunits(s) = Vector{UInt8}(@static V6_COMPAT ? s : codeunits(s)) -_contains(s, r) = @static V6_COMPAT ? ismatch(r, s) : occursin(r, s) -_replace(s, p) = @static V6_COMPAT ? replace(s, p.first, p.second) : replace(s, p) -create_vector(T, len) = @static V6_COMPAT ? Vector{T}(len) : Vector{T}(undef, len) -read_vector(s, T, len) = @static V6_COMPAT ? read(s, T, len) : read!(s, create_vector(T, len)) - -@static if V6_COMPAT - const copyto! = copy! - export copyto! -else - using Dates - export now -end +parse_hex(T, s) = parse(T, s, base=16) +cvt_char(s) = Vector{Char}(s) +_codeunits(s) = Vector{UInt8}(codeunits(s)) +_contains(s, r) = occursin(r, s) +_replace(s, p) = replace(s, p) +create_vector(T, len) = Vector{T}(undef, len) +read_vector(s, T, len) = read!(s, create_vector(T, len)) + +using Dates +export now function sortsplit!(index::Vector{UInt16}, vec::Vector{Tuple{T, UInt16}}, base) where {T} sort!(vec) @@ -113,14 +105,8 @@ Base.getindex(str::AbstractPackedTable{T}, ind::Integer) where {T} = T(str.namtab[str.offsetvec[ind]+1:str.offsetvec[ind+1]]) Base.size(str::AbstractPackedTable) = (length(str.offsetvec)-1,) Base.IndexStyle(::Type{<:AbstractPackedTable}) = Base.IndexLinear() -@static if VERSION >= v"0.7.0-DEV.5127" - (Base.iterate(str::AbstractPackedTable, state::Integer=1) = - state < length(str.offsetvec) ? (getindex(str, state), state+1) : nothing) -else - Base.start(str::AbstractPackedTable) = 1 - Base.next(str::AbstractPackedTable, state) = (getindex(str, state), state+1) - Base.done(str::AbstractPackedTable, state) = state >= length(str.offsetvec) -end +Base.iterate(str::AbstractPackedTable, state::Integer=1) = + state < length(str.offsetvec) ? (getindex(str, state), state+1) : nothing # Get all indices that start with a string