Skip to content

Commit 55d0e2b

Browse files
authored
reduce Meta.parse calls (#158)
1 parent 1abbd37 commit 55d0e2b

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

src/Operators/Operator.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ end
371371

372372

373373
for OP in (:colstart,:colstop,:rowstart,:rowstop)
374-
defOP = Meta.parse("default_"*string(OP))
374+
defOP = Symbol(:default_, OP)
375375
@eval begin
376376
$OP(A::Operator, i::Integer) = $defOP(A,i)
377377
$OP(A::Operator, i::PosInfinity) = ℵ₀

src/Operators/banded/CalculusOperator.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ abstract type CalculusOperator{S,OT,T}<:Operator{T} end
77
## Note that all functions called in calculus_operator must be exported
88

99
macro calculus_operator(Op)
10-
ConcOp=Meta.parse("Concrete"*string(Op))
11-
WrappOp=Meta.parse(string(Op)*"Wrapper")
12-
DefaultOp=Meta.parse("Default"*string(Op))
10+
ConcOp = Symbol(:Concrete, Op)
11+
WrappOp = Symbol(Op, :Wrapper)
12+
DefaultOp = Symbol(:Default, Op)
1313
return esc(quote
1414
# The SSS, TTT are to work around #9312
1515
abstract type $Op{SSS,OT,TTT} <: CalculusOperator{SSS,OT,TTT} end

src/Operators/banded/Reverse.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

33
for TYP in (:ReverseOrientation,:Reverse)
4-
WRAP = Meta.parse(string(TYP)*"Wrapper")
4+
WRAP = Symbol(TYP, :Wrapper)
55
@eval begin
66
abstract type $TYP{T} <: Operator{T} end
77

src/Operators/functionals/CalculusFunctional.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ abstract type CalculusFunctional{S,T} <: Operator{T} end
77
##TODO: Add ConcreteOp
88

99
macro calculus_functional(Op)
10-
ConcOp=Meta.parse("Concrete"*string(Op))
11-
WrappOp=Meta.parse(string(Op)*"Wrapper")
10+
ConcOp = Symbol(:Concrete, Op)
11+
WrappOp = Symbol(Op, :Wrapper)
1212
return esc(quote
1313
abstract type $Op{SSS,TTT} <: CalculusFunctional{SSS,TTT} end
1414
struct $ConcOp{S,T} <: $Op{S,T}

src/Operators/general/algebra.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ bandwidths(P::PlusOperator) = P.bandwidths
3030
israggedbelow(P::PlusOperator) = isbandedbelow(P) || all(israggedbelow,P.ops)
3131

3232
for (OP,mn) in ((:colstart,:min),(:colstop,:max),(:rowstart,:min),(:rowstop,:max))
33-
defOP = Meta.parse("default_"*string(OP))
33+
defOP = Symbol(:default_, OP)
3434
@eval function $OP(P::PlusOperator,k::Integer)
3535
if isbanded(P)
3636
$defOP(P,k)
@@ -310,7 +310,7 @@ israggedbelow(P::TimesOperator) = isbandedbelow(P) || all(israggedbelow,P.ops)
310310
Base.stride(P::TimesOperator) = mapreduce(stride,gcd,P.ops)
311311

312312
for OP in (:rowstart,:rowstop)
313-
defOP=Meta.parse("default_"*string(OP))
313+
defOP = Symbol(:default_, OP)
314314
@eval function $OP(P::TimesOperator,k::Integer)
315315
if isbanded(P)
316316
return $defOP(P,k)
@@ -323,7 +323,7 @@ for OP in (:rowstart,:rowstop)
323323
end
324324

325325
for OP in (:colstart,:colstop)
326-
defOP=Meta.parse("default_"*string(OP))
326+
defOP = Symbol(:default_, OP)
327327
@eval function $OP(P::TimesOperator, k::Integer)
328328
if isbanded(P)
329329
return $defOP(P, k)

src/constructors.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ end
3838

3939
# default_Fun is the default constructor, based on evaluation and transforms
4040
# last argument is whether to splat or not
41-
default_Fun(::Type{T},f,d::Space{ReComp},pts::AbstractArray,::Type{Val{true}}) where {T,ReComp} =
41+
default_Fun(T::Type,f,d::Space,pts::AbstractArray,::Type{Val{true}}) =
4242
Fun(d,transform(d,T[f(x...) for x in pts]))
4343

44-
default_Fun(::Type{T},f,d::Space{ReComp},pts::AbstractArray,::Type{Val{false}}) where {T,ReComp} =
44+
default_Fun(T::Type,f,d::Space,pts::AbstractArray,::Type{Val{false}}) =
4545
Fun(d,transform(d,broadcast!(f, similar(pts, T), pts)))
4646

4747

48-
function default_Fun(f,d::Space{ReComp},n::Integer,::Type{Val{false}}) where ReComp
48+
function default_Fun(f,d::Space,n::Integer,::Type{Val{false}})
4949
pts=points(d, n)
5050
f1=f(pts[1])
5151
if isa(f1,AbstractArray) && size(d) size(f1)
@@ -57,7 +57,7 @@ function default_Fun(f,d::Space{ReComp},n::Integer,::Type{Val{false}}) where ReC
5757
default_Fun(Tprom,f,d,pts,Val{false})
5858
end
5959

60-
function default_Fun(f,d::Space{ReComp},n::Integer,::Type{Val{true}}) where ReComp
60+
function default_Fun(f,d::Space,n::Integer,::Type{Val{true}})
6161
pts=points(d, n)
6262
f1=f(pts[1]...)
6363
if isa(f1,AbstractArray) && size(d) size(f1)
@@ -69,9 +69,9 @@ function default_Fun(f,d::Space{ReComp},n::Integer,::Type{Val{true}}) where ReCo
6969
default_Fun(Tprom,f,d,pts,Val{true})
7070
end
7171

72-
default_Fun(f,d::Space{ReComp},n::Integer) where {ReComp} = default_Fun(f,d,n,Val{!hasnumargs(f,1)})
72+
default_Fun(f,d::Space,n::Integer) = default_Fun(f,d,n,Val{!hasnumargs(f,1)})
7373

74-
Fun(f,d::Space{ReComp},n::Integer) where {ReComp} = default_Fun(dynamic(f),d,n)
74+
Fun(f,d::Space,n::Integer) = default_Fun(dynamic(f),d,n)
7575

7676
# the following is to avoid ambiguity
7777
# Fun(f::Fun,d) should be equivalent to Fun(x->f(x),d)
@@ -144,12 +144,12 @@ Fun(f::Type, d::Space) = error("Not implemented")
144144

145145

146146
# special case constructors
147-
zeros(S::Space) = Fun(S,zeros(1))
148-
zeros(::Type{T}, S::Space) where {T<:Number} = Fun(S,zeros(T,1))
147+
zeros(S::Space) = zeros(Float64, S)
148+
zeros(T::Type, S::Space) = Fun(S,zeros(T,1))
149149

150150
# catch all
151-
ones(S::Space) = Fun(x->1.0,S)
152-
ones(::Type{T}, S::Space) where {T<:Number} = Fun(x->one(T),S)
151+
ones(S::Space) = ones(Float64, S)
152+
ones(T::Type, S::Space) = Fun(x->one(T),S)
153153

154154
function Fun(::typeof(identity), d::Domain)
155155
cd=canonicaldomain(d)
@@ -169,7 +169,7 @@ Fun(::typeof(identity), S::Space) = Fun(identity,domain(S))
169169
Fun(f::typeof(zero), d::Space) = zeros(eltype(domain(d)),d)
170170
Fun(f::typeof(one), d::Space) = ones(eltype(domain(d)),d)
171171

172-
Fun(f::Type, d::Domain) = Fun(f,Space(d))
172+
# Fun(f::Type, d::Domain) = Fun(f,Space(d))
173173
Fun(f, d::Domain) = Fun(f,Space(d))
174174

175175

0 commit comments

Comments
 (0)