@@ -38,38 +38,16 @@ julia> parse(Complex{Float64}, "3.2e-1 + 4.5im")
3838parse (T:: Type , str; base =  Int)
3939parse (:: Type{Union{}} , slurp... ; kwargs... ) =  error (" cannot parse a value as Union{}" 
4040
41- @noinline  function  _invalid_base (base)
42-     throw (ArgumentError (" invalid base: base must be 2 ≤ base ≤ 62, got $base " 
43- end 
44- 
45- @noinline  _invalid_digit (base, char) =  throw (ArgumentError (" invalid base $base  digit $(repr (char)) " 
46- 
47- function  parse_char (:: Type{T} , c:: AbstractChar , base:: Integer , throw:: Bool ) where  T
48-     a:: UInt8  =  (base <=  36  ?  10  :  36 )
49-     (2  <=  base <=  62 ) ||  _invalid_base (base)
50-     base =  base %  UInt8
51-     cp =  codepoint (c)
52-     cp =  cp >  0x7a  ?  0xff  :  cp %  UInt8
53-     d =  UInt8 (' 0' ≤  cp ≤  UInt8 (' 9' ?  cp -  UInt8 (' 0' : 
54-         UInt8 (' A' ≤  cp ≤  UInt8 (' Z' ?  cp -  UInt8 (' A' +  UInt8 (10 ) : 
55-         UInt8 (' a' ≤  cp ≤  UInt8 (' z' ?  cp -  UInt8 (' a' +  a : 
56-         0xff 
57-     d <  base ||  (throw ?  _invalid_digit (base, c) :  return  nothing )
58-     convert (T, d):: T 
59- end 
60- 
61- function  parse (:: Type{T} , c:: AbstractChar ; base:: Integer = 10 ) where  {T <:  Integer }
62-     @inline  parse_char (T, c, base, true )
41+ function  parse (:: Type{T} , c:: AbstractChar ; base:: Integer  =  10 ) where  T<: Integer 
42+     a:: Int  =  (base <=  36  ?  10  :  36 )
43+     2  <=  base <=  62  ||  throw (ArgumentError (" invalid base: base must be 2 ≤ base ≤ 62, got $base " 
44+     d =  ' 0' <=  c <=  ' 9' ?  c- ' 0' : 
45+         ' A' <=  c <=  ' Z' ?  c- ' A' + 10  : 
46+         ' a' <=  c <=  ' z' ?  c- ' a' + a  :  throw (ArgumentError (" invalid digit: $(repr (c)) " 
47+     d <  base ||  throw (ArgumentError (" invalid base $base  digit $(repr (c)) " 
48+     convert (T, d)
6349end 
6450
65- function  tryparse (:: Type{T} , c:: AbstractChar ; base:: Integer = 10 ) where  {T <:  Integer }
66-     @inline  parse_char (T, c, base, false )
67- end 
68- 
69- #  For consistency with parse(t, AbstractString), support a `base` argument only when T<:Integer
70- parse (:: Type{T} , c:: AbstractChar ) where  T =  @inline  parse_char (T, c, 10 , true )
71- tryparse (:: Type{T} , c:: AbstractChar ) where  T =  @inline  parse_char (T, c, 10 , false )
72- 
7351function  parseint_iterate (s:: AbstractString , startpos:: Int , endpos:: Int )
7452    (0  <  startpos <=  endpos) ||  (return  Char (0 ), 0 , 0 )
7553    j =  startpos
@@ -138,7 +116,8 @@ function tryparse_internal(::Type{T}, s::AbstractString, startpos::Int, endpos::
138116        return  nothing 
139117    end 
140118    if  ! (2  <=  base <=  62 )
141-         raise ?  _invalid_base (base) :  return  nothing 
119+         raise &&  throw (ArgumentError (LazyString (" invalid base: base must be 2 ≤ base ≤ 62, got " 
120+         return  nothing 
142121    end 
143122    if  i ==  0 
144123        raise &&  throw (ArgumentError (" premature end of integer: $(repr (SubString (s,startpos,endpos))) " 
257236    if  2  <=  base <=  62 
258237        return  base
259238    end 
260-     _invalid_base ( base)
239+     throw ( ArgumentError ( " invalid  base: base must be 2 ≤ base ≤ 62, got  $base " ) )
261240end 
262241
263242""" 
0 commit comments