Skip to content

Commit 89104c6

Browse files
authored
Require JSON instead of using Requires (#189)
Loading JSON is actually faster than using Requires.
1 parent b68934a commit 89104c6

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

Project.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ version = "0.5.3"
55
[deps]
66
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
77
Future = "9fa8497b-333b-5362-9e8d-4d0656e87820"
8+
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
89
Missings = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
910
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
1011
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
11-
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
1212

1313
[extras]
14-
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
1514
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1615

1716
[targets]
18-
test = ["JSON", "Test"]
17+
test = ["Test"]

src/CategoricalArrays.jl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module CategoricalArrays
1212
export cut, recode, recode!
1313

1414
using Compat
15-
using Requires
15+
using JSON
1616
using Reexport
1717

1818
# TODO: cannot @reexport in conditional, the below should be removed when 0.6 is deprecated
@@ -22,12 +22,6 @@ module CategoricalArrays
2222
using Printf
2323
end
2424

25-
function __init__()
26-
# JSON of CatValue is JSON of the value it refers to
27-
@require JSON="682c06a0-de6a-54ab-a142-c8b1cf79cde6" JSON.lower(x::CatValue) =
28-
JSON.lower(get(x))
29-
end
30-
3125
include("typedefs.jl")
3226

3327
include("buildfields.jl")

src/value.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ end
215215
Base.:<(y::AbstractString, x::CatValue) = invoke(<, Tuple{Any, CatValue}, y, x)
216216
Base.:<(::Missing, ::CatValue) = missing
217217

218+
# JSON of CatValue is JSON of the value it refers to
219+
JSON.lower(x::CatValue) = JSON.lower(get(x))
220+
218221
# AbstractString interface for CategoricalString
219222
Base.string(x::CategoricalString) = get(x)
220223
Base.eltype(x::CategoricalString) = Char

test/REQUIRE

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)