From 92e1a852bc93181a7279b9371d0a8e2abc59d8a6 Mon Sep 17 00:00:00 2001 From: Stefan Karpinski Date: Mon, 2 Apr 2012 00:48:59 -0700 Subject: [PATCH] Removing a method makes split on char 2x faster. Win! Helps with #661. We're now 6x faster than before. --- base/regex.jl | 2 +- base/string.jl | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/base/regex.jl b/base/regex.jl index 709099640bfd9..66ec0faa816ba 100644 --- a/base/regex.jl +++ b/base/regex.jl @@ -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 diff --git a/base/string.jl b/base/string.jl index 5fc0079bec4b8..ea871da4a8842 100644 --- a/base/string.jl +++ b/base/string.jl @@ -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) @@ -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)