Skip to content

Commit

Permalink
Removing a method makes split on char 2x faster. Win!
Browse files Browse the repository at this point in the history
Helps with #661. We're now 6x faster than before.
  • Loading branch information
StefanKarpinski committed Apr 2, 2012
1 parent f8699be commit 92e1a85
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion base/regex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ each_match_overlap(r::Regex, s::String) = RegexMatchIterator(r,s,true)

function split(s::String, regex::Regex, include_empty::Bool, limit::Integer)
s = cstring(s)
strs = String[]
i = j = start(s)
strs = typeof(s)[]
while !done(s,i) && (limit == 0 || length(strs) < limit)
m = match(regex,s,j)
if m == nothing
Expand Down
3 changes: 1 addition & 2 deletions base/string.jl
Original file line number Diff line number Diff line change
Expand Up @@ -773,8 +773,8 @@ rpad(s, n::Integer) = rpad(string(s), n, " ")

function split(s::String, delims, include_empty::Bool)
i = 1
strs = String[]
len = length(s)
strs = String[]
while true
tokstart = tokend = i
while !done(s,i)
Expand All @@ -797,7 +797,6 @@ end

split(s::String) = split(s, (' ','\t','\n','\v','\f','\r'), false)
split(s::String, x) = split(s, x, true)
split(s::String, x::Char, incl::Bool) = split(s, (x,), incl)

function print_joined(strings, delim, last)
i = start(strings)
Expand Down

0 comments on commit 92e1a85

Please sign in to comment.