Skip to content

Commit f149c79

Browse files
committed
Deprecate takebuf_string() and rename takebuf_array() to takebuf()
takebuf_string(b) is now simply String(takebuf(b)). Also remove jl_takebuf_string, which did the same conversion from array to string in C.
1 parent f56d594 commit f149c79

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+178
-205
lines changed

base/LineEdit.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ function refresh_multi_line(terminal::UnixTerminal, args...; kwargs...)
267267
termbuf = TerminalBuffer(outbuf)
268268
ret = refresh_multi_line(termbuf, terminal, args...;kwargs...)
269269
# Output the entire refresh at once
270-
write(terminal, takebuf_array(outbuf))
270+
write(terminal, takebuf(outbuf))
271271
flush(terminal)
272272
return ret
273273
end
@@ -668,7 +668,7 @@ function normalize_key(key::AbstractString)
668668
write(buf, c)
669669
end
670670
end
671-
return takebuf_string(buf)
671+
return String(takebuf(buf))
672672
end
673673

674674
function normalize_keys(keymap::Dict)
@@ -1501,7 +1501,7 @@ end
15011501
activate(m::ModalInterface, s::MIState, termbuf, term::TextTerminal) =
15021502
activate(s.current_mode, s, termbuf, term)
15031503

1504-
commit_changes(t::UnixTerminal, termbuf) = write(t, takebuf_array(termbuf.out_stream))
1504+
commit_changes(t::UnixTerminal, termbuf) = write(t, takebuf(termbuf.out_stream))
15051505
function transition(f::Function, s::MIState, mode)
15061506
if mode === :abort
15071507
s.aborted = true

base/REPL.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ function respond(f, repl, main; pass_empty = false)
646646
if !ok
647647
return transition(s, :abort)
648648
end
649-
line = takebuf_string(buf)
649+
line = String(takebuf(buf))
650650
if !isempty(line) || pass_empty
651651
reset(repl)
652652
val, bt = send_to_backend(f(line), backend(repl))
@@ -840,7 +840,7 @@ function setup_interface(repl::LineEditREPL; hascolor = repl.hascolor, extra_rep
840840
return
841841
end
842842
edit_insert(sbuffer, input)
843-
input = takebuf_string(sbuffer)
843+
input = String(takebuf(sbuffer))
844844
oldpos = start(input)
845845
firstline = true
846846
isprompt_paste = false

base/REPLCompletions.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ function complete_methods(ex_org::Expr)
331331
# Check if the method's type signature intersects the input types
332332
if typeintersect(Tuple{method.sig.parameters[1 : min(na, end)]...}, t_in) != Union{}
333333
show(io, method, kwtype=kwtype)
334-
push!(out, takebuf_string(io))
334+
push!(out, String(takebuf(io)))
335335
end
336336
end
337337
return out

base/base64.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function base64encode(f::Function, args...)
176176
b = Base64EncodePipe(s)
177177
f(b, args...)
178178
close(b)
179-
takebuf_string(s)
179+
String(takebuf(s))
180180
end
181181
base64encode(x...) = base64encode(write, x...)
182182

base/c.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ transcode{T<:Union{Int32,UInt32}}(::Type{T}, src::Vector{UInt8}) = transcode(T,
167167
function transcode{S<:Union{Int32,UInt32}}(::Type{UInt8}, src::Vector{S})
168168
buf = IOBuffer()
169169
for c in src; print(buf, Char(c)); end
170-
takebuf_array(buf)
170+
takebuf(buf)
171171
end
172172
transcode(::Type{String}, src::String) = src
173173
transcode(T, src::String) = transcode(T, src.data)

base/datafmt.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -643,9 +643,9 @@ function writedlm(io::IO, a::AbstractMatrix, dlm; opts...)
643643
writedlm_cell(pb, a[i, j], dlm, quotes)
644644
j == lastc ? write(pb,'\n') : print(pb,dlm)
645645
end
646-
(nb_available(pb) > (16*1024)) && write(io, takebuf_array(pb))
646+
(nb_available(pb) > (16*1024)) && write(io, takebuf(pb))
647647
end
648-
write(io, takebuf_array(pb))
648+
write(io, takebuf(pb))
649649
nothing
650650
end
651651

@@ -677,9 +677,9 @@ function writedlm(io::IO, itr, dlm; opts...)
677677
pb = PipeBuffer()
678678
for row in itr
679679
writedlm_row(pb, row, dlm, quotes)
680-
(nb_available(pb) > (16*1024)) && write(io, takebuf_array(pb))
680+
(nb_available(pb) > (16*1024)) && write(io, takebuf(pb))
681681
end
682-
write(io, takebuf_array(pb))
682+
write(io, takebuf(pb))
683683
nothing
684684
end
685685

base/deprecated.jl

+3
Original file line numberDiff line numberDiff line change
@@ -1058,4 +1058,7 @@ function reduced_dims0(dims::Dims, region)
10581058
map(last, reduced_dims0(map(n->OneTo(n), dims), region))
10591059
end
10601060

1061+
@deprecate takebuf_array takebuf
1062+
@deprecate takebuf_string(b) String(takebuf(b))
1063+
10611064
# End deprecations scheduled for 0.6

base/docs/helpdb/Base.jl

-8
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,6 @@ Compute the inverse sine of `x`, where the output is in radians.
5252
"""
5353
asin
5454

55-
"""
56-
takebuf_array(b::IOBuffer)
57-
58-
Obtain the contents of an `IOBuffer` as an array, without copying. Afterwards, the
59-
`IOBuffer` is reset to its initial state.
60-
"""
61-
takebuf_array
62-
6355
"""
6456
pointer(array [, index])
6557

base/exports.jl

+1-2
Original file line numberDiff line numberDiff line change
@@ -1165,8 +1165,7 @@ export
11651165
serialize,
11661166
skip,
11671167
skipchars,
1168-
takebuf_array,
1169-
takebuf_string,
1168+
takebuf,
11701169
truncate,
11711170
unmark,
11721171
watch_file,

base/io.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ function readuntil(s::IO, delim::Char)
400400
break
401401
end
402402
end
403-
return takebuf_string(out)
403+
return String(takebuf(out))
404404
end
405405

406406
function readuntil{T}(s::IO, delim::T)
@@ -445,7 +445,7 @@ function readuntil(s::IO, t::AbstractString)
445445
break
446446
end
447447
end
448-
return takebuf_string(out)
448+
return String(takebuf(out))
449449
end
450450

451451
readline() = readline(STDIN)

base/iobuffer.jl

+8-10
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,13 @@ function String(io::AbstractIOBuffer)
253253
return String(copy!(Array{UInt8}(io.size), 1, io.data, 1, io.size))
254254
end
255255

256-
function takebuf_array(io::AbstractIOBuffer)
256+
"""
257+
takebuf(b::IOBuffer)
258+
259+
Obtain the contents of an `IOBuffer` as an array, without copying. Afterwards, the
260+
`IOBuffer` is reset to its initial state.
261+
"""
262+
function takebuf(io::AbstractIOBuffer)
257263
ismarked(io) && unmark(io)
258264
if io.seekable
259265
nbytes = io.size
@@ -268,7 +274,7 @@ function takebuf_array(io::AbstractIOBuffer)
268274
end
269275
return data
270276
end
271-
function takebuf_array(io::IOBuffer)
277+
function takebuf(io::IOBuffer)
272278
ismarked(io) && unmark(io)
273279
if io.seekable
274280
data = io.data
@@ -291,14 +297,6 @@ function takebuf_array(io::IOBuffer)
291297
return data
292298
end
293299

294-
"""
295-
takebuf_string(b::IOBuffer)
296-
297-
Obtain the contents of an `IOBuffer` as a string, without copying.
298-
Afterwards, the `IOBuffer` is reset to its initial state.
299-
"""
300-
takebuf_string(io::AbstractIOBuffer) = String(takebuf_array(io))
301-
302300
function write(to::AbstractIOBuffer, from::AbstractIOBuffer)
303301
if to === from
304302
from.ptr = from.size + 1

base/iostream.jl

+2-5
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,8 @@ function write(s::IOStream, c::Char)
218218
end
219219
read(s::IOStream, ::Type{Char}) = Char(ccall(:jl_getutf8, UInt32, (Ptr{Void},), s.ios))
220220

221-
takebuf_string(s::IOStream) =
222-
ccall(:jl_takebuf_string, Ref{String}, (Ptr{Void},), s.ios)
223-
224-
takebuf_array(s::IOStream) =
225-
ccall(:jl_takebuf_array, Vector{UInt8}, (Ptr{Void},), s.ios)
221+
takebuf(s::IOStream) =
222+
ccall(:jl_takebuf, Vector{UInt8}, (Ptr{Void},), s.ios)
226223

227224
function takebuf_raw(s::IOStream)
228225
sz = position(s)

base/markdown/Common/block.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ function indentcode(stream::IO, block::MD)
115115
break
116116
end
117117
end
118-
code = takebuf_string(buffer)
118+
code = String(takebuf(buffer))
119119
!isempty(code) && (push!(block, Code(rstrip(code))); return true)
120120
return false
121121
end
@@ -179,7 +179,7 @@ function blockquote(stream::IO, block::MD)
179179
end
180180
empty && return false
181181

182-
md = takebuf_string(buffer)
182+
md = String(takebuf(buffer))
183183
push!(block, BlockQuote(parse(md, flavor = config(block)).content))
184184
return true
185185
end
@@ -237,7 +237,7 @@ function admonition(stream::IO, block::MD)
237237
end
238238
end
239239
# Parse the nested block as markdown and create a new Admonition block.
240-
nested = parse(takebuf_string(buffer), flavor = config(block))
240+
nested = parse(String(takebuf(buffer)), flavor = config(block))
241241
push!(block, Admonition(category, title, nested.content))
242242
return true
243243
end
@@ -326,7 +326,7 @@ function list(stream::IO, block::MD)
326326
return true
327327
end
328328
end
329-
pushitem!(list, buffer) = push!(list.items, parse(takebuf_string(buffer)).content)
329+
pushitem!(list, buffer) = push!(list.items, parse(String(takebuf(buffer))).content)
330330

331331
# ––––––––––––––
332332
# HorizontalRule

base/markdown/GitHub/GitHub.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ function fencedcode(stream::IO, block::MD)
2121
if startswith(stream, string(ch) ^ n)
2222
if !startswith(stream, string(ch))
2323
if flavor == "math"
24-
push!(block, LaTeX(takebuf_string(buffer) |> chomp))
24+
push!(block, LaTeX(String(takebuf(buffer)) |> chomp))
2525
else
26-
push!(block, Code(flavor, takebuf_string(buffer) |> chomp))
26+
push!(block, Code(flavor, String(takebuf(buffer)) |> chomp))
2727
end
2828
return true
2929
else

base/markdown/parse/parse.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ function parseinline(stream::IO, md::MD, config::Config)
5656
char = Char(peek(stream))
5757
if haskey(config.inner, char) &&
5858
(inner = parseinline(stream, md, config.inner[char])) !== nothing
59-
c = takebuf_string(buffer)
59+
c = String(takebuf(buffer))
6060
!isempty(c) && push!(content, c)
6161
buffer = IOBuffer()
6262
push!(content, inner)
6363
else
6464
write(buffer, read(stream, Char))
6565
end
6666
end
67-
c = takebuf_string(buffer)
67+
c = String(takebuf(buffer))
6868
!isempty(c) && push!(content, c)
6969
return content
7070
end

base/markdown/parse/util.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ function readuntil(stream::IO, delimiter; newlines = false, match = nothing)
143143
while !eof(stream)
144144
if startswith(stream, delimiter)
145145
if count == 0
146-
return takebuf_string(buffer)
146+
return String(takebuf(buffer))
147147
else
148148
count -= 1
149149
write(buffer, delimiter)
@@ -190,7 +190,7 @@ function parse_inline_wrapper(stream::IO, delimiter::AbstractString; rep = false
190190
if !(char in whitespace || char == '\n' || char in delimiter) && startswith(stream, delimiter^n)
191191
trailing = 0
192192
while startswith(stream, delimiter); trailing += 1; end
193-
trailing == 0 && return takebuf_string(buffer)
193+
trailing == 0 && return String(takebuf(buffer))
194194
write(buffer, delimiter ^ (n + trailing))
195195
end
196196
end

base/multimedia.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ _textreprmime(m::MIME"text/plain", x::AbstractString) =
6363
function _binreprmime(m::MIME, x)
6464
s = IOBuffer()
6565
verbose_show(s, m, x)
66-
takebuf_array(s)
66+
takebuf(s)
6767
end
6868
_binreprmime(m::MIME, x::Vector{UInt8}) = x
6969

base/precompile.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ precompile(Base.systemerror, (Symbol, Bool))
389389
precompile(Base.take!, (Base.RemoteValue,))
390390
precompile(Base.take!, (RemoteChannel,))
391391
precompile(Base.take_ref, (Tuple{Int,Int},))
392-
precompile(Base.takebuf_string, (IOBuffer,))
392+
precompile(Base.takebuf, (IOBuffer,))
393393
precompile(Base.task_local_storage, ())
394394
precompile(Base.terminate_all_workers, ())
395395
precompile(Base.try_include, (String,))

base/printf.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ function gen_g(flags::String, width::Int, precision::Int, c::Char)
723723
# need to compute value before left-padding since trailing zeros are elided
724724
push!(blk.args, :(tmpout = IOBuffer()))
725725
push!(blk.args, :(print_fixed(tmpout,fprec,pt,len,$('#' in flags))))
726-
push!(blk.args, :(tmpstr = takebuf_string(tmpout)))
726+
push!(blk.args, :(tmpstr = String(takebuf(tmpout))))
727727
push!(blk.args, :(width -= length(tmpstr)))
728728
if '+' in flags || ' ' in flags
729729
push!(blk.args, :(width -= 1))
@@ -1111,7 +1111,7 @@ function bigfloat_printf(out, d, flags::String, width::Int, precision::Int, c::C
11111111
write(fmt, 'R')
11121112
write(fmt, c)
11131113
write(fmt, UInt8(0))
1114-
printf_fmt = takebuf_array(fmt)
1114+
printf_fmt = takebuf(fmt)
11151115
@assert length(printf_fmt) == fmt_len
11161116
bufsiz = length(DIGITS) - 1
11171117
lng = ccall((:mpfr_snprintf,:libmpfr), Int32, (Ptr{UInt8}, Culong, Ptr{UInt8}, Ptr{BigFloat}...), DIGITS, bufsiz, printf_fmt, &d)
@@ -1221,7 +1221,7 @@ macro sprintf(args...)
12211221
isa(args[1], AbstractString) || is_str_expr(args[1]) ||
12221222
throw(ArgumentError("@sprintf: first argument must be a format string"))
12231223
letexpr = _printf("@sprintf", :(IOBuffer()), args[1], args[2:end])
1224-
push!(letexpr.args[1].args, :(takebuf_string(out)))
1224+
push!(letexpr.args[1].args, :(String(takebuf(out))))
12251225
letexpr
12261226
end
12271227

base/replutil.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ function show_method_candidates(io::IO, ex::MethodError, kwargs::Vector=Any[])
553553
break
554554
end
555555
i += 1
556-
print(io, takebuf_string(line[1]))
556+
print(io, String(takebuf(line[1])))
557557
end
558558
end
559559
end

base/stream.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ end
690690

691691
function read(stream::LibuvStream)
692692
wait_readnb(stream, typemax(Int))
693-
return takebuf_array(stream.buffer)
693+
return takebuf(stream.buffer)
694694
end
695695

696696
function unsafe_read(s::LibuvStream, p::Ptr{UInt8}, nb::UInt)
@@ -735,7 +735,7 @@ function readavailable(this::LibuvStream)
735735
wait_readnb(this, 1)
736736
buf = this.buffer
737737
@assert buf.seekable == false
738-
return takebuf_array(buf)
738+
return takebuf(buf)
739739
end
740740

741741
function readuntil(this::LibuvStream, c::UInt8)
@@ -795,7 +795,7 @@ function flush(s::LibuvStream)
795795
end
796796
buf = get(s.sendbuf)
797797
if nb_available(buf) > 0
798-
arr = takebuf_array(buf) # Array of UInt8s
798+
arr = takebuf(buf) # Array of UInt8s
799799
uv_write(s, arr)
800800
end
801801
return

base/strings/basic.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ function map(f, s::AbstractString)
442442
end
443443
write(out, c2::Char)
444444
end
445-
String(takebuf_array(out))
445+
String(takebuf(out))
446446
end
447447

448448
function filter(f, s::AbstractString)
@@ -453,5 +453,5 @@ function filter(f, s::AbstractString)
453453
write(out, c)
454454
end
455455
end
456-
takebuf_string(out)
456+
String(takebuf(out))
457457
end

base/strings/io.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Create a string from any value using the [`showall`](:func:`showall`) function.
126126
function repr(x)
127127
s = IOBuffer()
128128
showall(s, x)
129-
takebuf_string(s)
129+
String(takebuf(s))
130130
end
131131

132132
# IOBuffer views of a (byte)string:
@@ -397,7 +397,7 @@ function unindent(str::AbstractString, indent::Int; tabwidth=8)
397397
write(buf, ' ')
398398
end
399399
end
400-
takebuf_string(buf)
400+
String(takebuf(buf))
401401
end
402402

403403
function convert(::Type{String}, chars::AbstractVector{Char})

0 commit comments

Comments
 (0)