Skip to content

Commit a5f275c

Browse files
highlander: remove all T <: String since String is concrete
1 parent fcacfb2 commit a5f275c

File tree

7 files changed

+28
-32
lines changed

7 files changed

+28
-32
lines changed

base/datafmt.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function result(dlmoffsets::DLMOffsets)
119119
dlmoffsets.oarr
120120
end
121121

122-
type DLMStore{T,S<:String} <: DLMHandler
122+
type DLMStore{T} <: DLMHandler
123123
hdr::Array{AbstractString, 2}
124124
data::Array{T, 2}
125125

@@ -128,29 +128,29 @@ type DLMStore{T,S<:String} <: DLMHandler
128128
lastrow::Int
129129
lastcol::Int
130130
hdr_offset::Int
131-
sbuff::S
131+
sbuff::String
132132
auto::Bool
133133
eol::Char
134134
end
135135

136-
function DLMStore{T,S<:String}(::Type{T}, dims::NTuple{2,Integer}, has_header::Bool, sbuff::S, auto::Bool, eol::Char)
136+
function DLMStore{T}(::Type{T}, dims::NTuple{2,Integer}, has_header::Bool, sbuff::String, auto::Bool, eol::Char)
137137
(nrows,ncols) = dims
138138
nrows <= 0 && throw(ArgumentError("number of rows in dims must be > 0, got $nrows"))
139139
ncols <= 0 && throw(ArgumentError("number of columns in dims must be > 0, got $ncols"))
140140
hdr_offset = has_header ? 1 : 0
141-
DLMStore{T,S}(fill(SubString(sbuff,1,0), 1, ncols), Array(T, nrows-hdr_offset, ncols), nrows, ncols, 0, 0, hdr_offset, sbuff, auto, eol)
141+
DLMStore{T}(fill(SubString(sbuff,1,0), 1, ncols), Array(T, nrows-hdr_offset, ncols), nrows, ncols, 0, 0, hdr_offset, sbuff, auto, eol)
142142
end
143143

144144
_chrinstr(sbuff::String, chr::UInt8, startpos::Int, endpos::Int) = (endpos >= startpos) && (C_NULL != ccall(:memchr, Ptr{UInt8}, (Ptr{UInt8}, Int32, Csize_t), pointer(sbuff.data)+startpos-1, chr, endpos-startpos+1))
145145

146-
function store_cell{T,S<:String}(dlmstore::DLMStore{T,S}, row::Int, col::Int, quoted::Bool, startpos::Int, endpos::Int)
146+
function store_cell{T}(dlmstore::DLMStore{T}, row::Int, col::Int, quoted::Bool, startpos::Int, endpos::Int)
147147
drow = row - dlmstore.hdr_offset
148148

149149
ncols = dlmstore.ncols
150150
lastcol = dlmstore.lastcol
151151
lastrow = dlmstore.lastrow
152152
cells::Array{T,2} = dlmstore.data
153-
sbuff::S = dlmstore.sbuff
153+
sbuff = dlmstore.sbuff
154154

155155
endpos = prevind(sbuff, nextind(sbuff,endpos))
156156
(endpos > 0) && ('\n' == dlmstore.eol) && ('\r' == Char(sbuff[endpos])) && (endpos = prevind(sbuff, endpos))
@@ -316,12 +316,12 @@ function dlm_fill(T::DataType, offarr::Vector{Vector{Int}}, dims::NTuple{2,Integ
316316
end
317317
end
318318

319-
function colval{S<:String}(sbuff::S, startpos::Int, endpos::Int, cells::Array{Bool,2}, row::Int, col::Int)
319+
function colval(sbuff::String, startpos::Int, endpos::Int, cells::Array{Bool,2}, row::Int, col::Int)
320320
n = tryparse_internal(Bool, sbuff, startpos, endpos, false)
321321
isnull(n) || (cells[row, col] = get(n))
322322
isnull(n)
323323
end
324-
function colval{T<:Integer, S<:String}(sbuff::S, startpos::Int, endpos::Int, cells::Array{T,2}, row::Int, col::Int)
324+
function colval{T<:Integer}(sbuff::String, startpos::Int, endpos::Int, cells::Array{T,2}, row::Int, col::Int)
325325
n = tryparse_internal(T, sbuff, startpos, endpos, 0, false)
326326
isnull(n) || (cells[row, col] = get(n))
327327
isnull(n)
@@ -336,11 +336,11 @@ function colval(sbuff::String, startpos::Int, endpos::Int, cells::Array{Float32,
336336
isnull(n) || (cells[row, col] = get(n))
337337
isnull(n)
338338
end
339-
function colval{T<:AbstractString, S<:String}(sbuff::S, startpos::Int, endpos::Int, cells::Array{T,2}, row::Int, col::Int)
339+
function colval{T<:AbstractString}(sbuff::String, startpos::Int, endpos::Int, cells::Array{T,2}, row::Int, col::Int)
340340
cells[row, col] = SubString(sbuff, startpos, endpos)
341341
return false
342342
end
343-
function colval{S<:String}(sbuff::S, startpos::Int, endpos::Int, cells::Array{Any,2}, row::Int, col::Int)
343+
function colval(sbuff::String, startpos::Int, endpos::Int, cells::Array{Any,2}, row::Int, col::Int)
344344
# if array is of Any type, attempt parsing only the most common types: Int, Bool, Float64 and fallback to SubString
345345
len = endpos-startpos+1
346346
if len > 0
@@ -359,15 +359,15 @@ function colval{S<:String}(sbuff::S, startpos::Int, endpos::Int, cells::Array{An
359359
cells[row, col] = SubString(sbuff, startpos, endpos)
360360
false
361361
end
362-
function colval{T<:Char, S<:String}(sbuff::S, startpos::Int, endpos::Int, cells::Array{T,2}, row::Int, col::Int)
362+
function colval{T<:Char}(sbuff::String, startpos::Int, endpos::Int, cells::Array{T,2}, row::Int, col::Int)
363363
if startpos == endpos
364364
cells[row, col] = next(sbuff, startpos)[1]
365365
return false
366366
else
367367
return true
368368
end
369369
end
370-
colval{S<:String}(sbuff::S, startpos::Int, endpos::Int, cells::Array, row::Int, col::Int) = true
370+
colval(sbuff::String, startpos::Int, endpos::Int, cells::Array, row::Int, col::Int) = true
371371

372372
function dlm_parse{T,D}(dbuff::T, eol::D, dlm::D, qchar::D, cchar::D,
373373
ign_adj_dlm::Bool, allow_quote::Bool, allow_comments::Bool,
@@ -376,7 +376,7 @@ function dlm_parse{T,D}(dbuff::T, eol::D, dlm::D, qchar::D, cchar::D,
376376
isascii(dlm) &&
377377
(!allow_quote || isascii(qchar)) &&
378378
(!allow_comments || isascii(cchar)))
379-
if (T <: String) && all_ascii
379+
if T === String && all_ascii
380380
return dlm_parse(dbuff.data, eol % UInt8, dlm % UInt8, qchar % UInt8, cchar % UInt8,
381381
ign_adj_dlm, allow_quote, allow_comments, skipstart, skipblanks, dh)
382382
end

base/hashing2.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ hash(x::Float16, h::UInt) = hash(Float64(x), h)
172172
const memhash = UInt === UInt64 ? :memhash_seed : :memhash32_seed
173173
const memhash_seed = UInt === UInt64 ? 0x71e729fd56419c81 : 0x56419c81
174174

175-
function hash{T<:String}(s::Union{T,SubString{T}}, h::UInt)
175+
function hash(s::Union{String,SubString{String}}, h::UInt)
176176
h += memhash_seed
177177
# note: use pointer(s) here (see #6058).
178178
ccall(memhash, UInt, (Ptr{UInt8}, Csize_t, UInt32), pointer(s), sizeof(s), h % UInt32) + h

base/parse.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function parseint_preamble(signed::Bool, base::Int, s::AbstractString, startpos:
5454
return sgn, base, j
5555
end
5656

57-
function tryparse_internal{S<:String}(::Type{Bool}, sbuff::S, startpos::Int, endpos::Int, raise::Bool)
57+
function tryparse_internal(::Type{Bool}, sbuff::String, startpos::Int, endpos::Int, raise::Bool)
5858
len = endpos-startpos+1
5959
p = pointer(sbuff)+startpos-1
6060
(len == 4) && (0 == ccall(:memcmp, Int32, (Ptr{UInt8}, Ptr{UInt8}, UInt), p, "true", 4)) && (return Nullable(true))
@@ -152,10 +152,10 @@ string(x::Union{Int8,Int16,Int32,Int64,Int128}) = dec(x)
152152
## string to float functions ##
153153

154154
tryparse(::Type{Float64}, s::String) = ccall(:jl_try_substrtod, Nullable{Float64}, (Ptr{UInt8},Csize_t,Csize_t), s, 0, sizeof(s))
155-
tryparse{T<:String}(::Type{Float64}, s::SubString{T}) = ccall(:jl_try_substrtod, Nullable{Float64}, (Ptr{UInt8},Csize_t,Csize_t), s.string, s.offset, s.endof)
155+
tryparse(::Type{Float64}, s::SubString{String}) = ccall(:jl_try_substrtod, Nullable{Float64}, (Ptr{UInt8},Csize_t,Csize_t), s.string, s.offset, s.endof)
156156

157157
tryparse(::Type{Float32}, s::String) = ccall(:jl_try_substrtof, Nullable{Float32}, (Ptr{UInt8},Csize_t,Csize_t), s, 0, sizeof(s))
158-
tryparse{T<:String}(::Type{Float32}, s::SubString{T}) = ccall(:jl_try_substrtof, Nullable{Float32}, (Ptr{UInt8},Csize_t,Csize_t), s.string, s.offset, s.endof)
158+
tryparse(::Type{Float32}, s::SubString{String}) = ccall(:jl_try_substrtof, Nullable{Float32}, (Ptr{UInt8},Csize_t,Csize_t), s.string, s.offset, s.endof)
159159

160160
tryparse{T<:Union{Float32,Float64}}(::Type{T}, s::AbstractString) = tryparse(T, bytestring(s))
161161

base/regex.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,6 @@ function match(re::Regex, str::Union{SubString{String}, String}, idx::Integer, a
172172
RegexMatch(mat, cap, ovec[1]+1, off, re)
173173
end
174174

175-
_utf8(str) = utf8(str)
176-
match{T<:String}(re::Regex, str::Union{T,SubString{T}}, idx::Integer, add_opts::UInt32=UInt32(0)) =
177-
match(re, _utf8(str), idx, add_opts)
178-
179175
match(r::Regex, s::AbstractString) = match(r, s, start(s))
180176
match(r::Regex, s::AbstractString, i::Integer) =
181177
throw(ArgumentError("regex matching is only available for bytestrings; use bytestring(s) to convert"))

base/strings/io.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ print(io::IO, s::AbstractString) = (write(io, s); nothing)
7070
write(io::IO, s::AbstractString) = (len = 0; for c in s; len += write(io, c); end; len)
7171
show(io::IO, s::AbstractString) = print_quoted(io, s)
7272

73-
write{T<:String}(to::AbstractIOBuffer, s::SubString{T}) =
73+
write(to::AbstractIOBuffer, s::SubString{String}) =
7474
s.endof==0 ? 0 : write_sub(to, s.string.data, s.offset + 1, nextind(s, s.endof) - 1)
7575

7676
## printing literal quoted string data ##
@@ -91,7 +91,7 @@ end
9191

9292
# IOBuffer views of a (byte)string:
9393
IOBuffer(str::String) = IOBuffer(str.data)
94-
IOBuffer{T<:String}(s::SubString{T}) = IOBuffer(sub(s.string.data, s.offset + 1 : s.offset + sizeof(s)))
94+
IOBuffer(s::SubString{String}) = IOBuffer(sub(s.string.data, s.offset + 1 : s.offset + sizeof(s)))
9595

9696
# join is implemented using IO
9797
function print_joined(io, strings, delim, last)

base/strings/types.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ prevind(s::SubString, i::Integer) = prevind(s.string, i+s.offset)-s.offset
7575

7676
convert{T<:AbstractString}(::Type{SubString{T}}, s::T) = SubString(s, 1, endof(s))
7777

78-
bytestring{T <: String}(p::SubString{T}) = bytestring(p.string.data[1+p.offset:p.offset+nextind(p, p.endof)-1])
78+
bytestring(p::SubString{String}) = bytestring(p.string.data[1+p.offset:p.offset+nextind(p, p.endof)-1])
7979

8080
function getindex(s::AbstractString, r::UnitRange{Int})
8181
if first(r) < 1 || endof(s) < last(r)
@@ -84,7 +84,7 @@ function getindex(s::AbstractString, r::UnitRange{Int})
8484
SubString(s, first(r), last(r))
8585
end
8686

87-
function cmp{T<:String,S<:String}(a::SubString{T}, b::SubString{S})
87+
function cmp(a::SubString{String}, b::SubString{String})
8888
na = sizeof(a)
8989
nb = sizeof(b)
9090
c = ccall(:memcmp, Int32, (Ptr{UInt8}, Ptr{UInt8}, UInt),
@@ -93,9 +93,9 @@ function cmp{T<:String,S<:String}(a::SubString{T}, b::SubString{S})
9393
end
9494

9595
# don't make unnecessary copies when passing substrings to C functions
96-
cconvert{T<:String}(::Type{Ptr{UInt8}}, s::SubString{T}) = s
97-
cconvert{T<:String}(::Type{Ptr{Int8}}, s::SubString{T}) = s
98-
function unsafe_convert{T<:String, R<:Union{Int8, UInt8}}(::Type{Ptr{R}}, s::SubString{T})
96+
cconvert(::Type{Ptr{UInt8}}, s::SubString{String}) = s
97+
cconvert(::Type{Ptr{Int8}}, s::SubString{String}) = s
98+
function unsafe_convert{R<:Union{Int8, UInt8}}(::Type{Ptr{R}}, s::SubString{String})
9999
unsafe_convert(Ptr{R}, s.string.data) + s.offset
100100
end
101101

base/unicode/utf32.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ convert{T<:AbstractString, S<:Union{UInt32,Char,Int32}}(::Type{T}, v::AbstractVe
127127
convert(T, utf32(v))
128128

129129
# specialize for performance reasons:
130-
function convert{T<:String, S<:Union{UInt32,Char,Int32}}(::Type{T}, data::AbstractVector{S})
130+
function convert{T<:Union{UInt32,Char,Int32}}(::Type{String}, data::AbstractVector{T})
131131
s = IOBuffer(Array(UInt8,length(data)), true, true)
132132
truncate(s,0)
133133
for x in data
134134
print(s, Char(x))
135135
end
136-
convert(T, takebuf_string(s))
136+
convert(String, takebuf_string(s))
137137
end
138138

139139
convert(::Type{Vector{UInt32}}, str::UTF32String) = str.data
@@ -227,7 +227,7 @@ pointer(x::String, i::Integer) = pointer(x.data)+(i-1)
227227
pointer(x::Union{UTF16String,UTF32String}, i::Integer) = pointer(x)+(i-1)*sizeof(eltype(x.data))
228228

229229
# pointer conversions of SubString of ASCII/UTF8/UTF16/UTF32:
230-
pointer{T<:String}(x::SubString{T}) = pointer(x.string.data) + x.offset
231-
pointer{T<:String}(x::SubString{T}, i::Integer) = pointer(x.string.data) + x.offset + (i-1)
230+
pointer(x::SubString{String}) = pointer(x.string.data) + x.offset
231+
pointer(x::SubString{String}, i::Integer) = pointer(x.string.data) + x.offset + (i-1)
232232
pointer{T<:Union{UTF16String,UTF32String}}(x::SubString{T}) = pointer(x.string.data) + x.offset*sizeof(eltype(x.string.data))
233233
pointer{T<:Union{UTF16String,UTF32String}}(x::SubString{T}, i::Integer) = pointer(x.string.data) + (x.offset + (i-1))*sizeof(eltype(x.string.data))

0 commit comments

Comments
 (0)