JuliaLang/julia — pull request #7145 by catawbasam (2014-06-05 19:17:19+00:00)
Title: specialize length(SubString) for DirectIndexString

passes 'make clean testall'

Double-checked code_typed( length,(SubString{ASCIIString},) ) to verify that this one actually affects execution :/

Current code_typed() output:
```
1-element Array{Any,1}:
:($(Expr(:lambda, {:s}, {{:i,:n,:#s406,:#s404,:c,:#s403,:j,:#s405,:_var0,:_var1,:_var2,:_var3},{{:s,SubString{ASCIIString},0},{:i,Int64,2},{:n,Int64,2},{:#s406,(Char,Int64),18},{:#s404,(Char,Int64),18},{:c,Char,18},{:#s403,(Int64,Int64),18},{:j,Int64,18},{:#s405,Int64,2},{:_var0,Char,18},{:_var1,Int64,18},{:_var2,Int64,18},{:_var3,Int64,18}},{}}, :(begin # string.jl, line 81:
i = 1 # line 82:
unless slt_int(top(getfield)(s::SubString{ASCIIString},:endof)::Int64,i::Int64)::Bool goto 0 # line 83:
return 0
0: # line 85:
n = 1 # line 86:
unless true goto 2
3: # line 87:
#s406 = next(s::SubString{ASCIIString},i::Int64)::(Char,Int64)
#s405 = 1
_var0 = tupleref(#s406::(Char,Int64),1)::Union(Int64,Char)
_var1 = box(Int64,add_int(1,1))::Int64
c = _var0::Char
#s405 = _var1::Int64
_var2 = tupleref(#s406::(Char,Int64),2)::Union(Int64,Char)
_var3 = box(Int64,add_int(2,1))::Int64
j = _var2::Int64
#s405 = _var3::Int64 # line 88:
unless slt_int(top(getfield)(s::SubString{ASCIIString},:endof)::Int64,j::Int64)::Bool goto 5 # line 89:
return n::Int64
5: # line 91:
n = box(Int64,add_int(n::Int64,1))::Int64 # line 92:
i = j::Int64
4:
unless false goto 3
2:
1:
return
end::Int64))))
```

Proposed code_typed() output:
```
1-element Array{Any,1}:
:($(Expr(:lambda, {:s}, {{},{{:s,SubString{ASCIIString},0}},{}}, :(begin # In[65], line 1:
return top(getfield)(s::SubString{ASCIIString},:endof)::Int64
end::Int64))))
```