File tree Expand file tree Collapse file tree 1 file changed +7
-16
lines changed Expand file tree Collapse file tree 1 file changed +7
-16
lines changed Original file line number Diff line number Diff line change @@ -79,9 +79,13 @@ object FromDigits {
79
79
}
80
80
if (i == len) throw MalformedNumber ()
81
81
while (i < len) {
82
- val c = digits(i)
83
- val d = digit2int(c, radix)
84
- if (d < 0 ) throw MalformedNumber ()
82
+ val ch = digits(i)
83
+ val d =
84
+ if (ch <= '9' ) ch - '0'
85
+ else if ('a' <= ch && ch <= 'z' ) ch - 'a' + 10
86
+ else if ('A' <= ch && ch <= 'Z' ) ch - 'A' + 10
87
+ else - 1
88
+ if (d < 0 || radix <= d) throw MalformedNumber ()
85
89
if (value < 0 ||
86
90
limit / (radix / divider) < value ||
87
91
limit - (d / divider) < value * (radix / divider) &&
@@ -92,19 +96,6 @@ object FromDigits {
92
96
if (negated) - value else value
93
97
}
94
98
95
- /** Convert a character digit to an Int according to given base,
96
- * -1 if no success
97
- */
98
- private def digit2int (ch : Char , base : Int ): Int = {
99
- val num = (
100
- if (ch <= '9' ) ch - '0'
101
- else if ('a' <= ch && ch <= 'z' ) ch - 'a' + 10
102
- else if ('A' <= ch && ch <= 'Z' ) ch - 'A' + 10
103
- else - 1
104
- )
105
- if (0 <= num && num < base) num else - 1
106
- }
107
-
108
99
/** Convert digit string to Int number
109
100
* @param digits The string to convert
110
101
* @param radix The radix
You can’t perform that action at this time.
0 commit comments