File tree 1 file changed +5
-19
lines changed
1 file changed +5
-19
lines changed Original file line number Diff line number Diff line change 42
42
function print (io:: IO , xs... )
43
43
lock (io)
44
44
try
45
- for x in xs
46
- print (io, x)
47
- end
45
+ foreach (Fix1 (print, io), xs)
48
46
finally
49
47
unlock (io)
50
48
end
@@ -138,32 +136,20 @@ function print_to_string(xs...)
138
136
if isempty (xs)
139
137
return " "
140
138
end
141
- siz:: Int = 0
142
- for x in xs
143
- siz += _str_sizehint (x)
144
- end
145
- # specialized for performance reasons
139
+ siz = sum (_str_sizehint, xs; init = 0 )
146
140
s = IOBuffer (sizehint= siz)
147
- for x in xs
148
- print (s, x)
149
- end
141
+ print (s, xs... )
150
142
String (_unsafe_take! (s))
151
143
end
152
144
153
145
function string_with_env (env, xs... )
154
146
if isempty (xs)
155
147
return " "
156
148
end
157
- siz:: Int = 0
158
- for x in xs
159
- siz += _str_sizehint (x)
160
- end
161
- # specialized for performance reasons
149
+ siz = sum (_str_sizehint, xs; init = 0 )
162
150
s = IOBuffer (sizehint= siz)
163
151
env_io = IOContext (s, env)
164
- for x in xs
165
- print (env_io, x)
166
- end
152
+ print (env_io, xs... )
167
153
String (_unsafe_take! (s))
168
154
end
169
155
You can’t perform that action at this time.
0 commit comments